如何将值传递给 React-Native-Router-Flux 中的其他组件?
问题描述:
我的代码是:
...
<Router>
<Scene key="com1" component={Com1} initial/>
<Scene key="com2" component={Com2}/>
</Router>
...
com1.js
...
onPress={Actions.com2}
我将 com1
改为 com2
.
但是我需要将Com1
的输入框的值传递给Com2
.
But I need to pass values for the inputbox of Com1
to Com2
.
我该怎么做?
答
你可以这样传递数据:
Actions.com2 ({text: 'Hello World'})
Actions.com2 ({text: 'Hello World'})
您可以像这样在 com2 中恢复数据:
You can recover your data in com2 like this:
this.props.text
this.props.text
您可以转到下一个教程了解更多信息:
You can go to the next tutorial for more information:
https://github.com/aksonov/react-native-router-flux/blob/master/docs/v3/MINI_TUTORIAL.md