Does React Native compile JavaScript into Java for Android?

前端 未结 6 1336
再見小時候
再見小時候 2020-12-05 01:43

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-

6条回答
  •  情书的邮戳
    2020-12-05 02:20

    Based on "React Made Native Easy" book:

    Essentially, React Native can be considered as a set of React components, where each component represents the corresponding native views and components.

    Also there is two parts in React Native architechture:

    1. Native Code/Modules: Most of the native code in case of iOS is written in Objective C or Swift, while in the case of Android it is written in Java. But for writing our React Native app, we would hardly ever need to write native code for iOS or Android.

    2. Javascript VM: The JS Virtual Machine that runs all our JavaScript code. On iOS/Android simulators and devices React Native uses JavaScriptCore, which is the JavaScript engine that powers Safari. JavaScriptCore is an open source JavaScript engine originally built for WebKit. In case of iOS, React Native uses the JavaScriptCore provided by the iOS platform. It was first introduced in iOS 7 along with OS X Mavericks.

    And for communication between these parts:

    React Native Bridge: React Native bridge is a C++/Java bridge which is responsible for communication between the native and Javascript thread. A custom protocol is used for message passing.

提交回复
热议问题