React Native was a leader in cross-platform app development, but traditional bridge-based designs showed limitations in performance and scalability. To solve these problems, React Native JSI (JavaScript Interface)
A new architecture has been introduced as the center.
Let's take a look at how technologies such as TurboModels, Fabric, and Hermes have actually brought about performance changes in combination with JSI, and how they can be used in practice.
Existing React Native used Bridge to call Native from Javascript. Bridge played a role in connecting the different environments called Javascript and Native. There was an issue where Bridge was slow to connect these different environments
Why is it slower when using Bridge, and why is it faster when using JSI?
This issue was caused by linking Javascript to another environment called native. JSI is a principle that all of the above problems disappear because Javascript and Native are directly connected. Let's understand the principles of Bridge and JSI and look at changes in React Native.
In existing React Native, native modules were loaded all at once during the app initialization phase.
TurboModules is a new architecture introduced in React Native to improve the performance of native modules. The existing native module method uses Bridge to transfer data to calls between JavaScript and native code, and there was a problem where performance deteriorated during the serialization/deserialization process. TurboModules solves this problem and improves performance.
To use TurboModule, you must first implement a new native module. This module defines an interface between JavaScript and native code using the TurboModule architecture.
In Javascript, you can use it as follows:
What is the existing React Native UI rendering engine YogaIt was. Yoga is a layout engine developed by Facebook and used in React Native to calculate the UI's layout. Yoga was designed to provide the same layout across platforms, and mainly worked by passing layout data calculated in JavaScript to native code.
However, the existing React Native UI rendering engine had the following issues.
fabricis a newly introduced UI engine to solve this problem. It uses JSI (JavaScript Interface) to synchronize the UI state between JavaScript and native code in real time, and to process layout calculations more efficiently.
List rendering
Fabric provides a smooth user experience even when rendering large lists. For example, scrolling remains smooth even in a scrolling list containing thousands of items.
Using Fabric, the above code works more optimally internally, and can process more data without scrolling delays.
Previously, React Native used common JavaScript engines such as JSC (JavaScriptCore) or V8, but there were many parts that were not optimized for mobile environments.
To solve this, Hermes tried to solve the criteria problem as follows:
1. Fast app launch
Hermes optimizes app initialization speed so users can use apps faster.
2. Support for low-end devices
Thanks to its low memory usage, it runs smoothly even on low-end Android devices. For example, using Hermes in apps targeting the Southeast Asian market can help increase market share.
React Native's new architecture organically combines JSI, TurboModels, Fabric, and Hermes to provide the following effects:
React Native has now evolved into a platform that can overcome performance limitations, even for large-scale applications. React Native as well as other hybrid frameworks use Bridge, but they are gradually applying other methods. Apps created with a hybrid framework are trying to extract the same performance as Native, and this change in React Native should also be paid attention to in terms of performance.