0

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.

Ravindhiran
  • 5,304
  • 9
  • 50
  • 82
  • Possible duplicate of [How to pass data From one Scene to another in ReactNaive](https://stackoverflow.com/questions/42621845/how-to-pass-data-from-one-scene-to-another-in-reactnaive) – Bat Oct 01 '17 at 20:41

2 Answers2

1

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

Greg Billetdeaux
  • 2,039
  • 13
  • 9
1

You can write this to TwoScene:

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

In params, you get pass data :

params.passProps.myProp
Nidhi Patel
  • 1,222
  • 11
  • 17
  • https://stackoverflow.com/questions/44298025/react-native-0-44-stack-navigator-example/44299087?noredirect=1#comment75610297_44299087 can fix this issue ? – Ravindhiran Jun 01 '17 at 09:51