T
TanStack5mo ago
eastern-cyan

Prevent useBlocker from showing alert on reload

im using useBlocker when i have a dialog open to make the back arrow instead going back in navigation closing the dialog, this works as expected but i dont want the alert on reload when the dialog its open, is there a way to prevent that but still make the back button close the dialog?
No description
3 Replies
eastern-cyan
eastern-cyanOP5mo ago
also is there a better way to handle dialogs native of the router? i tried with history state but i ended up wiht a solution that added a lot of unnecesary entries to the history
fair-rose
fair-rose3w ago
same question here, I want to align the behavior to block nav for reload/go back/redirect tho
extended-salmon
extended-salmon3w ago
Yeah, useBlockerhook recieves also enableBeforeUnload which can be a function that returns a boolean, or a boolean. by defining it as false, it will remove this message.

Did you find this page helpful?