This migration guide is intended for authors of React Native libraries and application developers. It explains how to deploy the new Architecture, including the new NativeModule system (TurboModule) and the new Renderer (Fabric), to iOS and Android libraries and apps.
Prerequisites for Applications
It must meet a few prerequisites before enabling the new architecture in the application.
Use a React Native nightly release
You must now use a React Native nightly release to get the most recent updates. We will eventually suggest aiming for a minimal stable open-source release.
Install react-native-codegen​
Check that you are using the most recent version of the react-native-codegen NPM package. It is 0.0.13 at the time of this writing.
Android specifics
There are various prerequisites for using the new architecture on Android:
Gradle 7.x and the Android Gradle Plugin 7.x is being used.
Making use of the new React Gradle Plugin
Creating React-native from the Source
Enabling the New NativeModule System (TurboModule) in your App
Android
1. Enable NDK and the native build
The code-gen will generate some Java and C++ code, which we must now build.
2. Adapt your ReactNativeHost to use the ReactPackageTurboModuleManagerDelegate​
The class you developed may then be sent to your ReactNativeHost. You may find your ReactNativeHost by looking for the getReactNativeHost function (). The ReactNativeHost is often found within your Application class.
3. C++ Provide a native implementation for the methods in your *TurboModuleDelegate class
If you look closely at the previously created class MyApplicationTurboModuleManagerDelegate, you will find that some of the functions are native.
4. Enable the useTurboModules flag in your Application onCreate​
Finally, you may enable TurboModule functionality in the application. To do so, enable the useTurboModule flag in the Application onCreate function.
Most JavaScript application code does not need to change due to the new architecture in terms of backward compatibility. The Java/ObjC code for custom View Managers and Native Modules must be changed, although many may be React Native Architecturecode-modified to work with the new system. A compatibility layer that allows bespoke View Managers and Native Modules to continue operating in the new system may also be built.
In terms of timeframes, most of the JSI code has already been deposited in the repository while writing. A considerable percentage of the Fabric code is already in the repository, and TurboModules upgrades are still being released. It is generally backward compatible; there is no need for a single release date but rather a steady rollout.
Click here to read more:
https://evincedev.com/blog/how-to-support-new-react-native-architecture-in-your-mobile-app/