Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does React Native compile JavaScript into Java for Android?

When I develop hybrid apps with React Native. Does the JavaScript code I write transform into Java-Code or Java-Bytecode for the Dalvik/ART Runtime when I create an Android-App from my React Native code? Or are just the UI components compiled into native UI components? Or does a library like the Fetch API compile the JavaScript code into Java-Code or Java-Bytecode?

like image 477
unlimited101 Avatar asked Dec 13 '16 15:12

unlimited101


People also ask

How does React Native compile to Android?

React Native compiles the JavaScript code to native components, thus, using platform-specific APIs and modules. By using such native components as Images, Text, and View as building blocks, software developers can create new ones.

Does React Native convert to Java?

The code remains the JavaScript native code and is not converted into any other format.

What JavaScript engine does React Native use on Android?

JavaScript Runtime​ When using React Native, you're going to be running your JavaScript code in two environments: In most cases, React Native will use JavaScriptCore, the JavaScript engine that powers Safari.

Does React Native compile to Java or Kotlin?

React Native uses JavaScript to compile the app's user interface, but using native-OS views. For more complex features, it allows code implementation in OS-native languages (Swift and Objective-C for iOS, and Java and Kotlin for Android).


1 Answers

Basically, you write Javascript. The Javascript communicates with native components (Java on Android, Objective C on iOS, C# on Windows).

The communication occurs through the so-called "bridge". If at any time you feel that this communication slows things down too much, you can choose to implement the Javascript functionality in Java, Objective C, or C# respectively in order to run purely native. In this case, you are writing directly in native code, so there's no Javascript to native compilation.

This will sacrifice compatibility for performance. Normally, this is not necessary.

  • Further reading

Understanding React Native bridge concept

like image 109
Marc Avatar answered Oct 03 '22 10:10

Marc