T
TanStack6mo ago
noble-gold

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-gold
noble-goldOP6mo ago
After some investigation, I found out about enableBeforeUnload, it would be really nice if this would accept a Promise like shouldBlockFn
vicious-gold
vicious-gold6mo ago
cc @ferretwithabéret
funny-blue
funny-blue6mo 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.

Did you find this page helpful?