Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: useBlocker block twice when navigating on a page using setSearchParams #11144

Open
tpoisseau opened this issue Dec 27, 2023 · 0 comments
Labels

Comments

@tpoisseau
Copy link

What version of React Router are you using?

6.21.1

Steps to Reproduce

  1. a controllable shouldBlock state
  2. a page locking navigation on mount, unlocking it on dismount. It could be a form page, locking if form is dirty, unlocking when form is submit (navigate after submit)
  3. a page using setSearchParams on mount

I prepared a whole bug reproduction repository so feel free to use it and tweak it :
https://stackblitz.com/edit/uhn4nr-react-router-useblocker-issue?file=README.md

Expected Behavior

After blocker.proceed() I expect navigating to new page without having to confirm twice, even if the page opened do a setSearchParams on mount. because on the second confirmation, my shouldBlock is false, but blocker state is blocking.

Actual Behavior

After confirming navigation (blocker.proceed()) the navigation happen. shouldBlock is false but setSearchParams is blocked, open a new confirmation modal which should be confirmed once again.

Best regards,

@tpoisseau tpoisseau added the bug label Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant