Skip to content

[Bug]: Getting "A router only supports one blocker at a time" warning during HMR when running your navigation-blocking example #11430

Open
@simonbaas

Description

@simonbaas

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions