Skip to content

Instantly share code, notes, and snippets.

@dvrajan
Last active March 18, 2018 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvrajan/720c16479b9aa1e60872540b7c8be2b0 to your computer and use it in GitHub Desktop.
Save dvrajan/720c16479b9aa1e60872540b7c8be2b0 to your computer and use it in GitHub Desktop.
Blogpost example ReactScreen
public class ReactScreen extends Activity implements DefaultHardwareBackBtnHandler {
protected ReactInstanceManager reactInstanceManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
reactInstanceManager = ReactInstanceManager.builder()
.setApplication(this.getApplication())
.setBundleAssetName("react.android.bundle")
.setJSMainModulePath("index")
.addPackage(new MainReactPackage())
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
ReactRootView reactRootView = new ReactRootView(this);
reactRootView.startReactApplication(reactInstanceManager, "Index");
setContentView(reactRootView);
}
@Override
public void invokeDefaultOnBackPressed() {
super.onBackPressed();
}
//Implement other lifecycle methods here and delegate to ReactInstanceManager
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment