如何将值传递给 React-Native-Router-Flux 中的其他组件? [英] How to pass values to other component in React-Native-Router-Flux?

查看:44
本文介绍了如何将值传递给 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

这篇关于如何将值传递给 React-Native-Router-Flux 中的其他组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆