I have been using switchNavigator to navigate between views but now I'm testing out drawerNavigator. With switch it's fairly easy to pass props since I'm navigating through a button, something like this:
this.navigate({
routeName: 'Home',
key: 'Home',
params: {
username: this.state.username
}
});
It's not done the same way on a drawer though, it seems? So how is it supposed to be done? Thanks
You can try like this to pass the params
this.props.navigation.navigate('Home', { userName: this.state.username });
And you can get the params from the component like this
const { userName } = this.props.navigation.state.params;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.