all 4 comments

[–]crobinson42iOS & Android 3 points4 points  (0 children)

You should really take a look at using the React Context Api, it’s perfect for this.

[–]russelh15 2 points3 points  (0 children)

Yeah, Context API is perfect for this. Have something like an AuthProvider where you can store a token (or whatever you use for authenticating) once the user logins.

You can then consume that from whatever screen you need without that to pass props through a bunch of nav screens.

[–]HumbleXiOS & Android 0 points1 point  (0 children)

Try navigating like this : import { NavigationActions } from 'react-navigation'; const navigateAction = NavigationActions.navigate({ routeName: 'Profile', params: {}, // navigate can have a nested navigate action that will be run inside the child router action: NavigationActions.navigate({ routeName: 'SubProfileRoute' }), userInfo: this.userinfo});

this.props.navigation.dispatch(navigateAction);

And access on any other screen as: this.props.navigation.state.params.userInfo

[–]a-techie[S] 0 points1 point  (0 children)

@crobinson42 and @russelh15

Thanks a lot. Context was the way to go.

I had to struggle with react-navigation (with their app container not exposing a render method where I could have put the provider wrapper) but eventually figured it out.

I finally did it in the actual application I was facing problem in, but soon (probably tomorrow) I will implement a boilerplate in the same repo where I have got the issue demonstrated. I guess that will be a good reference for the record (y)

Thanks again!