Example usage for com.facebook.react ReactRootView startReactApplication

List of usage examples for com.facebook.react ReactRootView startReactApplication

Introduction

In this page you can find the example usage for com.facebook.react ReactRootView startReactApplication.

Prototype

public void startReactApplication(ReactInstanceManager reactInstanceManager, String moduleName,
        @Nullable Bundle initialProperties) 

Source Link

Document

#startReactApplication(ReactInstanceManager, String, android.os.Bundle, String)

Usage

From source file:com.github.markzhai.react.preloader.ReactPreLoader.java

License:Apache License

/**
 * Pre-load {@link ReactRootView} to local {@link Map}, you may want to
 * load it in previous activity./*from   w ww  .  ja v a 2  s  .  c o m*/
 */
public static void init(Activity activity, ReactInfo reactInfo) {
    if (CACHE_VIEW_MAP.get(reactInfo.getMainComponentName()) != null) {
        return;
    }
    ReactRootView rootView = new ReactRootView(new MutableContextWrapper(activity));
    rootView.startReactApplication(
            ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
            reactInfo.getMainComponentName(), reactInfo.getLaunchOptions());
    CACHE_VIEW_MAP.put(reactInfo.getMainComponentName(), rootView);
}