You may track if your able to go back like this :
const prevGetStateForAction = Navigator.router.getStateForAction;
Navigator.router.getStateForAction = (action, state) => {
// Do not allow to go back from Login
if (action.type === "Navigation/BACK" && state && state.routes[state.index].routeName === "Login") {
return null;
}
// Do not allow to go back to Login
if (action.type === "Navigation/BACK" && state) {
const newRoutes = state.routes.filter(r => r.routeName !== "Login");
const newIndex = newRoutes.length - 1;
return prevGetStateForAction(action, { index: newIndex, routes: newRoutes });
}
return prevGetStateForAction(action, state);
};
See this :
https://github.com/react-community/react-navigation/issues/295
react-native-navigation
library forreact-native
, not the browser. I've added it to the title to be more clear.