React native startup process on Android

Startup performance is a big part of performance optimization on react native applications. And knowing how it was started is the first step to optimize it. This article will focus on how react views binded with modules in JS.

I’d like to start with how you integrate react native to your existing application. The integrating is simple, but the logic behind it is a little complex.

According to the document, you add a ReactRootView and call method startReactApplication on it with ReactInstanceManager and the corresponding module name.

Each ReactInstanceManager holds an instance of CatalystInstance, when you call ReactRootView#startReactApplication, the view will attached to the CatalystInstance.

When attaching, if the CatalystInstance is already initialized, ReactRootView#runApplication will called, if not, initialize the CatalystInstance in background.

ReactRootView#runApplication will still be called when CatalystInstance is initialized since that view is attached to it. (When initialized, runApplication of all attached ReactRootViewwill be called.)