I'm trying to disable back button after successful login into the application but couldn't make it. I'm using react router dom 5.2.0 for routing. Currently, I'm redirecting to login page if someone clicks to browser back button but I need to block the back button.
useEffect(() => {
return () => {
if (history.action === "POP") {
history.replace('/login');
}
};
}, [history]);