I have some issue with BackHandler, the issue is
when running the app and go to the let\'s say Sign Up screen and touch the back in my mobile they w
You can check for the screen has been focused prior to call the alert instead of checking the routeName from navigation.
the updated code might look like this.
if (this.props.navigation.isFocused()) {
Alert.alert(
"Exit App",
"Do you want to exit?",
[
{
text: "No",
onPress: () => console.log("Cancel Pressed"),
style: "cancel"
},
{ text: "Yes", onPress: () => BackHandler.exitApp() }
],
{ cancelable: false }
);
}