Show custom UI popup before reloading page not possible
Hey guys! I successfully implemented a custom UI popup when navigating from one page to another but not when reloading a page, it still shows the default browser popup. Is this a limitation of useBlocker?
3 Replies
noble-goldOP•6mo ago
After some investigation, I found out about
enableBeforeUnload
, it would be really nice if this would accept a Promise like shouldBlockFn
vicious-gold•6mo ago
cc @ferretwithabéret
funny-blue•6mo ago
At a guick glance,
enableBeforeUnload
cannot easily accept a Promise
right now. You can open an issue/feature request on github so we can track this, I have some ideas but none of them are tested.
One approach would be to always prevent the beforeunload
event emitted by the window
, waiting for the enableBeforeUnload
async function to execute and then redoing the navigation with ignoreBlocker: true
if the navigation should have not been blocked. I am leaving this here as some sort of documentation in case someone wants to try opening a PR.