原生初始化时initialProperties向StackNavigator screen传值

1.原生initialProperties

 

Bundle bundle=new Bundle();

bundle.putString(RNConstants.RN_INIT_SERVER_KEY,serverKey);

bundle.putString(RNConstants.RN_INIT_UA,ua);

mReactRootView.startReactApplication(mReactInstanceManager, moduleName, bundle);

 

2.使用screenProps接收

const App = StackNavigator({

SplashScreen: { screen: SplashScreen},

ProfileScreen: {screen: ProfileScreen},

});

 

class GlobalConfig extends React.Component{

render(){

return

}

}

 

AppRegistry.registerComponent('android', () => GlobalConfig);

 

3.screen中使用

return (

native initialProps is {JSON.stringify(this.props.screenProps)}

);

参考:https://github.com/react-navigation/react-navigation/issues/876

demo地址:https://github.com/RightOfHand/NativeRMaven

你可能感兴趣的:(react-native)