T
TanStack15mo ago
mere-teal

Is there a way to cancel a navigation event in Route.beforeLoad?

Am building an Electron app, where we want some urls to open in a separate window. We would like to handle this on a router or route level instead of manually opening popup windows. Trying to accomplish this by checking for specific urls in the root route beforeLoad method, but I can't find a way of cancelling the navigation event.
4 Replies
provincial-silver
provincial-silver15mo ago
I don't think we have this right now. you could maybe workaround this by using a blocker? can you please create a feature request as a GitHub discussion describe your use case and how an API could look like. ideally also provide links to how other routers provide similar functionality
mere-teal
mere-tealOP15mo ago
Couldn't come up with a reliable way to use a blocker since blockers don't have access to the location
provincial-silver
provincial-silver15mo ago
we have a PR for enhancing blockers, but this needs some work if you want you can look into it
provincial-silver
provincial-silver15mo ago
GitHub
feat: Update useBlocker hook to provide current and next location...
Currently, when using the useBlocker hook there is no way to ascertain where the navigation being blocked is headed. For my usage of blocking, this is necessary to allow navigation within a selecte...

Did you find this page helpful?