StackNavigator is my configuration.
How do to redirect to another screen after user pressed login and successfully obtained a token. Below are the current screen.
const MainScreenNavigator = StackNavigator({
Login: { screen: LoginScreen },
Protected: { screen: ProtectedScreen },
});
StackNavigator is my configuration.
How do to redirect to another screen after user pressed login and successfully obtained a token. Below are the current screen.
const MainScreenNavigator = StackNavigator({
Login: { screen: LoginScreen },
Protected: { screen: ProtectedScreen },
});
Share
Improve this question
edited Jul 16, 2017 at 15:39
Sydney
1,4391 gold badge16 silver badges22 bronze badges
asked Jun 16, 2017 at 20:40
JoseJose
331 gold badge1 silver badge4 bronze badges
1 Answer
Reset to default 3use navigate('Protected')
and if you want to pass params navigate('protected',{user:'John'})
and retrive it as props this.props.Navigation.state.params.user
class LoginScreen extends React.Component {
static navigationOptions = {
title : 'Login'
};
login() {
const { navigate } = this.props.navigation;
navigate('Protected', { user: 'John' })
};
render() {
return (
<View>
<Button
onPress={() => this.login()}
title="Login"
/>
</View>
)
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744787949a4593741.html
评论列表(0条)