How to pass a parameter in react native navigator?

react-native, react-navigation, reactjs

Solution

Normal props on a Navigator component can be used to configure the navigator.

To send arbitrary props to the screens, you have to use `screenProps`.

So for example:

<StudentStackNav screenProps={{ name: 'Lucy' }}/>

Which will be available in `StudentLogin` as `this.props.screenProps`.

`screenProps` is documented on this page

Problem

I tried an example of React Native Navigator: ``` const StudentStackNav = StackNavigator({ Home: { screen: StudentLogin, } }); ``` How do I pass a parameter to StudentStackNav and pass it to StudentLogin? I have tried `<StudentStackNav name='Lucy'>` but `this.props.name` is not available in `Home`.

Original source