Last active
May 25, 2023 22:38
-
-
Save Tymek/df2021b77fcea20cabaef46bbee8b001 to your computer and use it in GitHub Desktop.
Next.js block navigation on unsaved changes
Please how do I use It in my js code.
Does not work when window.confirm() is false, still navigates away
Please how do I use It in my js code.
function MyComponent() {
// call the hook
// you may pass a custom message useNavigationLock(true, 'Don't leave please');
useNavigationLock();
return <p>Here's how you use it</p>;
}
I found an issue. When I click the cancel button it clear the states.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
React Hook useEffect has missing dependencies: 'router.events' and 'warningText'.
Either include them or remove the dependency array.
[react-hooks/exhaustive-deps]
(facebook/react#14920)