import { useEffect } from "react";

const preventNav = evt => {
  evt.preventDefault();
  evt.returnValue = '';
}

const usePreventNavigation = () => useEffect(() => {
  window.addEventListener("beforeunload", preventNav);
  return () => window.removeEventListener("beforeunload", preventNav);
}, []);

export default usePreventNavigation;