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
Currently, useBlocker will always add a beforeunload event listener, which triggers a blocking alert box when leaving the page or closing the tab. However, there are situations where you might want to block internal navigation but don't want to block unload.
This would align it with react-router's behavior, which recommends users to set their own beforeunload listener instead.
Maybe just a prop like this could make sense to make it backwards compatible?
Looking at the source code it would need to pass the option to the history's block method, which currently only accepts functions, but I don't know if that also needs to remain backwards compatible. In that case maybe it could be added as a second argument?
Edit: Seems like #1790 might solve this issue, adding disableBeforeUnload as an option 👍
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently,
useBlocker
will always add abeforeunload
event listener, which triggers a blocking alert box when leaving the page or closing the tab. However, there are situations where you might want to block internal navigation but don't want to block unload.This would align it with
react-router
's behavior, which recommends users to set their ownbeforeunload
listener instead.Maybe just a prop like this could make sense to make it backwards compatible?
Looking at the source code it would need to pass the option to the
history
's block method, which currently only accepts functions, but I don't know if that also needs to remain backwards compatible. In that case maybe it could be added as a second argument?Edit: Seems like #1790 might solve this issue, adding
disableBeforeUnload
as an option 👍Beta Was this translation helpful? Give feedback.
All reactions