mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-10 22:47:58 +08:00
Add appProperty to ReactRootView
Summary: To get on par with iOS this PR adds an `appProperty` to the `ReactRootView`. The documentation on the iOS side is here: [https://facebook.github.io/react-native/docs/communication-ios.html#properties.](https://facebook.github.io/react-native/docs/communication-ios.html#properties.) You can pass in initial props with the `startReactApplication` method: ```java … Bundle initialProps = new Bundle(); bundle.putString(“initialKey”, “initialValue”); mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", initialProps); setContentView(mReactRootView); … ``` And later on properties can be updated this way: ```java … // Update props Bundle updatedProps = mReactRootView.getAppProperties(); updatedProps.putString(“someOtherKey”, “someOtherValue”); mReactRootView.setAppProperties(updatedProps); // Replace props Bundle newProps = new Bundle(); newProps.putString(“someKey”, “someValue”); mReactRootView.setAppProperties(newProps); … Closes https://github.com/facebook/react-native/pull/13430 Reviewed By: AaaChiuuu Differential Revision: D4896483 Pulled By: javache fbshipit-source-id: 7c752d6bbf5dc500874b49dcff80db772e83915f
This commit is contained in:
committed by
Facebook Github Bot
parent
3d2a9ebdda
commit
57b0039ce1
@@ -839,14 +839,7 @@ public class ReactInstanceManager {
|
||||
UIManagerModule uiManagerModule = catalystInstance.getNativeModule(UIManagerModule.class);
|
||||
int rootTag = uiManagerModule.addMeasuredRootView(rootView);
|
||||
rootView.setRootViewTag(rootTag);
|
||||
@Nullable Bundle launchOptions = rootView.getLaunchOptions();
|
||||
WritableMap initialProps = Arguments.makeNativeMap(launchOptions);
|
||||
String jsAppModuleName = rootView.getJSModuleName();
|
||||
|
||||
WritableNativeMap appParams = new WritableNativeMap();
|
||||
appParams.putDouble("rootTag", rootTag);
|
||||
appParams.putMap("initialProps", initialProps);
|
||||
catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams);
|
||||
rootView.runApplication();
|
||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user