Forked from ferrannp/splash-screen-createReactActivityDelegate.java
Created
May 6, 2023 00:35
-
-
Save paulayo93/3cc465a543bea720080a4973f0527e4f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MainActivity.java | |
@Override | |
protected ReactActivityDelegate createReactActivityDelegate() { | |
return new ReactActivityDelegate(this, getMainComponentName()) { | |
@Override | |
protected ReactRootView createRootView() { | |
return new RNGestureHandlerEnabledRootView(MainActivity.this); | |
} | |
@Override | |
protected void loadApp(String appKey) { | |
if (mReactRootView != null) { | |
throw new IllegalStateException("Cannot loadApp while app is already running."); | |
} | |
mReactRootView = createRootView(); | |
mReactRootView.startReactApplication( | |
getReactNativeHost().getReactInstanceManager(), | |
appKey, | |
getLaunchOptions()); | |
} | |
@Override | |
protected void onDestroy() { | |
if (mReactRootView != null) { | |
mReactRootView.unmountReactApplication(); | |
mReactRootView = null; | |
} | |
if (getReactNativeHost().hasInstance()) { | |
getReactNativeHost().getReactInstanceManager().onHostDestroy(getPlainActivity()); | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment