disable the go back button when a user is logged in react code example
Example: react prevent back
const preventBack = (): void => {
window.history.pushState(null, "", window.location.pathname);
}
const handleBack = (): void => {
console.log('handleBack')
}
useEffect(() => {
preventBack();
window.addEventListener('popstate', handleBack);
return () => {
window.removeEventListener('popstate', handleBack)
}
});