showing results for - "react prevent back"
Oskar
14 Feb 2018
1const preventBack = (): void => {
2  window.history.pushState(null, "", window.location.pathname);
3}
4
5const handleBack = (): void => {
6  console.log('handleBack')
7}
8
9useEffect(() => {
10  preventBack();
11  window.addEventListener('popstate', handleBack);
12  return () => {
13    window.removeEventListener('popstate', handleBack)
14  }
15});