Skip to content

How to intercept route changes caused by setting a query param value #476

Discussion options

You must be logged in to vote

Hi @franky47 Thanks so much for the timely reply. I've spent several hours on this, and I realized that my use case is actually more specific.

Essentially I'm using router events to display a confirmation modal when a user tries to update the url. The confirmation modal is only rendered when specific conditions are met (in this scenario, when ?willBlockNavigation=true). The problem was actually caused because the source of truth from nuqs seems to be its own internal state (NOT the url value). As a result, when the nuqs setter method is called, it is removing the router event listener BEFORE the url is updated, which explains why the modal didn't display for me when a user updates another…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ryanhopperlowe
Comment options

Answer selected by ryanhopperlowe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants