我有一个使用react-native-router-flux
充实的项目,并且试图通过props
传递对象。 通常,我可以调用Actions.someKey({ someProp: object })
进行导航,但是我试图使用rightButtonImage
进行导航,因为它无法访问组件的props
。
例如:
Router.js
<Router>
<Scene1
rightButtonImage={someImage}
onRight={() => Actions.sceneTwo()}
/>
<Scene2 key="sceneTwo" />
</Router>
当我移至Scene2时,我想传递一个Scene1组件可以访问的对象。
这可能对您有帮助:在每个组件中,例如在componentDidMount中,您可以执行以下操作:
Actions.refresh({
rightTitle: "Next",
rightButtonTextStyle: {color: 'red'},
onRight: this.goSomewhere,
rightButtonImage: someImage
})