disable back button in react-router 2
Your best bet, is when the user is login he/ she is redirected to dashbaord. if for some reason the user click on back button you should:
if the user is logged in stay on the page dashboard
if(logged) {
history.pushState(null, null, location.href);
window.onpopstate = function(event) {
history.go(1);
};
}
it will be not possible to go back.
Applying all these hacks the URL changes to login
for a moment and then to wherever-we-push
.
Instead, what we can do is: In login, where api endpoint returns success, do:
history.replace('/Whatever_screen')
This will remove login screen from window.history
stack, and the screen will not flicker.