2017-06-01 173 views
0

我是新的反应原生,我有两个场景OnceScene和TwoScene我想从OnceScene导航到TwoScene,并在同一时间我想传递一些字符串或从第1阵列第二届所以我写了下面的代码传递数据从一个场景到另一个在ReactNaive

let nextRoute = { 
     component: TwoScene, 
     title: 'TwoScene', 
     passProps: { myProp: 'bar', searchText: 'pass data', } 
    }; 
       this.props.navigator.push(nextRoute); 

你可以看到我传递的字符串中passProps,但我怎么能接取在TwoScene它该字符串似乎很简单,但由于我是新的我没有太多的想法。

+0

[如何在ReactNaive中将数据从一个场景传递到另一个场景](https://stackoverflow.com/questions/42621845/how-to-pass-data-from-one-scene-to-another-in-reactnaive) – Bat

回答

1

我相信myPropsearchText应该可以访问如this.props.myPropthis.props.searchText在TwoScene

1

你可以写这TwoScene:

const { params } = this.props.navigation.state; 

在PARAMS,你会得到通数据:

params.passProps.myProp 
+0

https://stackoverflow.com/questions/44298025/react -native-0-44-stack-navigator-example/44299087?noredirect = 1#comment75610297_44299087能解决这个问题吗? – Ravindhiran

相关问题