react-nativereact-native-router-flux

How to pass values to other component in React-Native-Router-Flux?


My code is:

...
<Router>
 <Scene key="com1" component={Com1} initial/>
<Scene key="com2" component={Com2}/>
</Router>
...
com1.js
...
onPress={Actions.com2}

I changed com1 to com2.

But I need to pass values for the inputbox of Com1 to Com2.

How can I do that?


Solution

  • You can pass data like this:

    Actions.com2 ({text: 'Hello World'})

    You can recover your data in com2 like this:

    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