How React Native works?
This article will describe how react-native works when develop react native mobile applications. Before reading this if you want to know what is react native is please refer to this.
A react-native application is a collection of special react components that used to build user interfaces and compiled to native widgets to run on native Android and iOS devices.
To achieve this, react-native connects javascript/typescript code with native java/Swift/Objective-C codes by using native platform APIs exposed to javascript.
React native includes four types of threads such as Main/UI thread, Javascript thread, Native module thread, Render thread.
Initially, UI/Main thread will start loading js bundle and Javascript thread start executions in the application logic.
UI/Main thread and Javascript thread will never share data between each other and only use serialized messages.
UI/Main thread compiled views into Native Views and Javascripts thread execute javascript logics (Ex: touch events, API calls, etc).
Javascript thread executed javascript logics will handle by the Native module thread and Render thread and communicate with the Native platform module via the bridge.
Finally compiled views will show on the native device as same as native views.
- Views compiled, therefore views are mostly causing to the perforations of the application.
- Therefore we can improve the performance of the application by simplifying the Views and separating the UIs from the logics.
References
Read More