Pass data From one Scene to another in ReactNaive

☆樱花仙子☆ 提交于 2019-12-25 16:54:21

问题


I'm new in react native, i have two Scene OnceScene and TwoScene I want to Navigate from OnceScene to TwoScene and at the same time i want to pass some string or array from 1st the 2nd so for that i have written the below code

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

you can see i am passing the string in passProps but how can i acess that string in TwoScene Its seems simple but since i am new i dont have much idea.


回答1:


I believe myProp and searchText should be accessible as this.props.myProp and this.props.searchText in TwoScene




回答2:


You can write this to TwoScene:

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

In params, you get pass data :

params.passProps.myProp


来源:https://stackoverflow.com/questions/44297787/pass-data-from-one-scene-to-another-in-reactnaive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!