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]: Getting "A router only supports one blocker at a time" warning when running your navigation-blocking example #11430

Open
simonbaas opened this issue Apr 9, 2024 · 7 comments
Labels

Comments

@simonbaas
Copy link

simonbaas commented Apr 9, 2024

What version of React Router are you using?

6.22.3

Steps to Reproduce

  1. Clone react-router repo and navigate into examples/navigation-blocking
  2. Update react-router-dom to 6.22.3 (same issue on ^6.21.0 though)
  3. Run npm install
  4. Start dev server: npm run dev
  5. On page go to http://localhost:3000/three (Three (Form with blocker)
  6. In code editor, press save on app.tsx so vite HMR runs
  7. Go back to web page and click on another link
  8. Notice warning in console

Expected Behavior

Not getting the warning. Any blocker should be disposed/cleaned up correctly.

Actual Behavior

Getting warning "A router only supports one blocker at a time" in console.

I'm seeing this issue in real world case as well, even if useBlocker is only called once in the entire app. It the component which calls useBlocker is "mounted" (in lack of better term) and the router is re-created higher up it seems like the old blocker is not disposed/removed/cleanup correctly.

@simonbaas simonbaas added the bug label Apr 9, 2024
@elvince
Copy link

elvince commented Apr 19, 2024

Hi,
I'm facing exactly this bug also.

If a new router is recreated while a useBlocker is "active/mounted", it is not reseted properly.

Thanks for your help in fixing this.

@JasonDyke
Copy link

I've been seeing this same issue for a while now, but after updating to react-router-dom v6.23.0 today I haven't seen it again.

Can anyone else confirm that this issue is fixed in 6.23.0?

@Jose4gg
Copy link

Jose4gg commented Apr 26, 2024

@JasonDyke it is still happening to me in 6.23.0

@simonbaas
Copy link
Author

Same issue still exists on 6.23.0.

@kubmir
Copy link

kubmir commented Apr 28, 2024

Same issue for me on 6.23.0. In fact, it also really prevents navigation for me. The last version which worked for me was 6.13.0 - all versions since then breaks navigation after form submission for me.

@elvince
Copy link

elvince commented Apr 29, 2024

Same issue still exists on 6.23.0.

@ptim
Copy link

ptim commented May 3, 2024

Not sure if this is a valid solution, but I notice in the example:
https://github.com/remix-run/react-router/blob/main/examples/navigation-blocking/src/app.tsx#L42

if (import.meta.hot) {
  import.meta.hot.dispose(() => router.dispose());
}

...seems to resolve the warning for me

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

6 participants