React-native: [Android] modal cannot work if ReactRootView is created and cached in previous activity

Created on 21 Aug 2016  路  2Comments  路  Source: facebook/react-native

When I do pre-load of ReactRootView in previous Activity (in a hybrid app):

        ReactRootView rootView = new ReactRootView(activity);
        rootView.startReactApplication(
                ((ReactApplication) activity.getApplication()).getReactNativeHost().getReactInstanceManager(),
                reactInfo.getMainComponentName(),
                reactInfo.getLaunchOptions());

and later use the created view in ReactActivity directly

setContentView(mReactRootView);

Modal cannot show in this case then (works fine if I do not do this pre-load), I guess this is due to Android window issue as it is using the previous native activity to add window.

Any ideas on this? TimePickerAndroid works just fine.

react-native 0.31, Mac, Android.

Locked

Most helpful comment

@jokester it works, thanks

All 2 comments

Creating ReactRootView with a MutableContextWrapper might be a workaround (so we can change underlying Context in the 2nd Activity).

@jokester it works, thanks

Was this page helpful?
0 / 5 - 0 ratings