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
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
Please how do I use It in my js code.