Reputation: 7892
From one of tab of Tabbar while pressing Logout i added this function to navigate to login screen :
logout() {
AuthenticationService.logout();
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Login'})],
key : null
})
this.props.navigation.dispatch(resetAction);
}
It works succcessfully but when i again click Login button from Login screen it gives warning :Here is screenshots -
Could you please suggest me whats wrong i am doing here ?
Here is Logout method :
async logout() {
try {
await authService.signOut()
console.log("User successfully logged out")
return true
} catch (err) {
console.error("Log out failure", err)
Alert.alert("Logout failed", "Try again")
return false
}
}
Upvotes: 1
Views: 87
Reputation: 300
I don't see any problem with the code you are posting, I assume the problem is related to your login, api might be failing. You can add proper error handling in your login action/reducer and don't forget to set loggedIn state to false when logout is successful assuming you are using redux.
Upvotes: 1