Open
Description
What version of React Router are you using?
6.22.3
Steps to Reproduce
- Clone react-router repo and navigate into examples/navigation-blocking
- Update react-router-dom to 6.22.3 (same issue on ^6.21.0 though)
- Run npm install
- Start dev server: npm run dev
- On page go to http://localhost:3000/three (Three (Form with blocker)
- In code editor, press save on app.tsx so vite HMR runs
- Go back to web page and click on another link
- 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.