react-native-lazy-index is a RAM bundle friendly, bundle-time generated
index.js. Improve your app startup time by only loading features you'll use on
For information on RAM bundles and inline requires, see React Native Performance.
npm install --save react-native-lazy-index
so you'll need to configure Babel to include it. The recommended way is to add
it to your
package.json, add a section called
"experiences" with the features
that should be lazy loaded. In the example below, we have four features keyed on
react-native-lazy-index in your
On the native side, you can now load your experiences by invoking
ReactExperienceLoader.load(). As an example, we will load two features,
// AndroidReactInstanceManager reactInstanceManager = reactNativeHost.;ReactContext reactContext = reactInstanceManager.;CatalystInstance catalystInstance = reactContext.;WritableNativeArray features = new WritableNativeArray();features.;features.;catalystInstance.;
With a naive
index.js, all features will be loaded when your app starts and
React Native is initialized for the first time.
By loading features on demand, we can improve app startup time.
react-native-lazy-index, we no longer load all features up front.
index.js registers a callable module,
allowing full control over when a feature is loaded. Features that are never
used, should never be loaded.
const BatchedBridge = ;BatchedBridge;
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.