I have a editor page, I want to give user a prompt when user try to navigate away if the work is not saved .
I found something like this for react, I am wondering if readwood router can do something like this:
https://javascript.plainenglish.io/how-to-alert-a-user-before-leaving-a-page-in-react-a2858104ca94
Thanks!
That might be a react router v6 limitation unfortunately, you can see here: https://github.com/remix-run/react-router/issues/8139
Scratch that answer, I don’t know why I thought redwood used react router v6… It doesn’t, but I don’t see any possibility for prompt with the redwood router
Tobbe
July 21, 2022, 6:34am
5
The standard way of handling this is the beforeunload
event. Does that not work for you? There is nothing built-in to the redwood router for this
will before unload be fired when switch route?
dsmith
November 9, 2023, 7:29pm
7
Hey! I wanted to confirm that window.onbeforeunload doesn’t work. Is there any functionality like a useBlocker or react-router’s component?
anyone figure out a way to handle this? window.onbeforeunload works for closing the tab, not for clicking around in the app