You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm developing an app where I need to prevent "back button" in some cases, (e.g.: when I'm editing a form and I click back button I should receive a confirmation dialog before the navigation occurs).
I tried adding the well known beforeunload event. But it only works when the navigation was not made via pushState/setLocation.
Is it possible to achieve the behavior I need with wouter?
The text was updated successfully, but these errors were encountered:
You can try creating a custom hook that wraps default useBrowserLocation and checks for unsaved changes before actual navigate is called. Here, I found the demo that was initially written for V2 but I think it still works:
Thanks for your reply, but the provided link is not loading :(
Anyway, are you sure that navigation caused by "browser's back button" can be prevented?
I tried to create the custom hook as you suggested but I'm definetely missing some info.
I'm developing an app where I need to prevent "back button" in some cases, (e.g.: when I'm editing a form and I click back button I should receive a confirmation dialog before the navigation occurs).
I tried adding the well known
beforeunload
event. But it only works when the navigation was not made viapushState
/setLocation
.Is it possible to achieve the behavior I need with wouter?
The text was updated successfully, but these errors were encountered: