Skip to content

Commit

Permalink
Provide a method to easily provide initial props to a ReactAndroid ap…
Browse files Browse the repository at this point in the history
…plication

Summary:
Adds back support for initial props in ReactAndroid while maintaining the abstraction benefits of having the details of ReactActivity abstracted from the end user's MainActivity. This does remove the need for ReactRootView's two paramater version of the overloaded startReactApplication as far as I can tell but I wasn't sure if anyone might be using that method internally.
Closes facebook#5384

Reviewed By: svcscm

Differential Revision: D2841602

Pulled By: androidtrunkagent

fb-gh-sync-id: 07e0937bbbdb3ac1585aa252e2fd0f3736690898
  • Loading branch information
mangogogos authored and christopherdro committed Jan 20, 2016
1 parent f70db7c commit 9a8c01a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ protected String getJSMainModuleName() {
return "index.android";
}

/**
* Returns the launchOptions which will be passed to the {@link ReactInstanceManager}
* when the application is started. By default, this will return null and an empty
* object will be passed to your top level component as its initial props.
* If your React Native application requires props set outside of JS, override
* this method to return the Android.os.Bundle of your desired initial props.
*/
protected @Nullable Bundle getLaunchOptions() {
return null;
}

/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
Expand Down Expand Up @@ -128,7 +139,7 @@ protected void onCreate(Bundle savedInstanceState) {

mReactInstanceManager = createReactInstanceManager();
ReactRootView mReactRootView = createRootView();
mReactRootView.startReactApplication(mReactInstanceManager, getMainComponentName());
mReactRootView.startReactApplication(mReactInstanceManager, getMainComponentName(), getLaunchOptions());
setContentView(mReactRootView);
}

Expand Down

0 comments on commit 9a8c01a

Please sign in to comment.