usePreventNavigate() #14
Replies: 1 comment
-
|
This proposal became the following RFC issue - #15 Let's continue the discussion there |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What's the motivation for this proposal?
Problems you are trying to solve:
Goals you are trying to achieve:
Proposed Solution / Feature
What do you propose?
We add
usePreventNavigate(cb), which registers a handler that will be called when there is a navigation event. When the handler returnstrue, navigation is blocked.This is actually not trivial to implement correctly because not all navigation passes through qwik-city, and when the browser is involved the answer need to be synchronous.
If the navigation attempt is going through qwik-city, the callback will receive the URL of the desired target. This makes it possible to perform the navigation later.
Code examples
using a modal library:
Using a separate modal:
Links / References
Remix Router has
useBlocker, there are interesting tidbits in their decisions document.Beta Was this translation helpful? Give feedback.
All reactions