New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intercept the location change #39
Comments
Hi @hakankaraduman Here is a backbone of the app: import { Router } from "wouter";
// the standard hook used
import useLocation from "wouter/use-location";
const useInterruptibleLocation = () => {
const [location, setLocation] = useLocation();
const changeLocation = href => {
// write your own logic here, call setLocation when location needs to be changed
}
return [location, changeLocation];
}
// you'll need this at the top-level to tell wouter to use your hook instead of the default one
<Router hook={useInterruptibleLocation} > I'll try to get back with a real demo later. |
Hi again @hakankaraduman, I'm going to close the issue, hope you don't mind. |
Hi,
I could not see on the docs how to intercept the location change from a component.
Let's say I have a dirty state at the current page and want to use a custom modal component to alert the user if they want to move forward and lose data.
Thanks
The text was updated successfully, but these errors were encountered: