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

Eric Chan picture Eric Chan · Sep 21, 2016 · Viewed 34.3k times · Source

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?

Answer

Alexandre Teixeira picture Alexandre Teixeira · Sep 21, 2016

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