Created
December 7, 2021 09:16
-
-
Save hieptl/2a941c0cc97a6260a0e91ff299dc0d37 to your computer and use it in GitHub Desktop.
app.js - logout - Zocdoc Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleLogout = (navigation) => { | |
cometChat.logout().then( | |
() => { | |
AsyncStorage.removeItem('auth'); | |
setUser(null); | |
navigation.reset({ | |
index: 0, | |
routes: [{ name: 'Login' }] | |
}); | |
}, error => { | |
console.log("Logout failed with exception:", { error }); | |
} | |
); | |
}; | |
const logout = (navigation) => () => { | |
Alert.alert( | |
"Confirm", | |
"Do you want to log out?", | |
[ | |
{ | |
text: "Cancel", | |
style: "cancel" | |
}, | |
{ text: "OK", onPress: () => handleLogout(navigation) } | |
] | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment