Incompatible with react-router v4.4.0-beta.6
See original GitHub issueI was upgrading an older app and attempting to use connected-react-router, and encountered the following error being generated by react-router when attempting to wrap Link
s and Switch
es in this library’s ConnectedRouter
.
Error: Invariant failed: You should not use <Link> outside a <Router>
Repro example: https://codesandbox.io/s/ymk0787ox
I’m not familiar with how react-router previously allowed other Router implementations, but it seems that this future version no longer will. I’m also unsure whether this is an issue with connected-react-router or a regression/problem that should be fixed in react-router but I wanted to get your input. Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8 (2 by maintainers)
Top Results From Across the Web
react BrowserRouter resulting in "You should not use <Route ...
Your react-router-dom version (beta.6) is incompatible with mdbreact library. If you install stable version ^4.3.1 everything will work ...
Read more >connected-react-router - npm
A Redux binding for React Router v4 and v5. Latest version: 6.9.3, last published: 6 months ago. Start using connected-react-router in your ...
Read more >Migrating to React Router v6: A complete guide
Migrate your React Router applications from v5 to v6 with this in-depth guide, including a review of additions and improvements from v5.
Read more >Upgrading from v5 v6.6.1 - React Router
React Router v6 makes heavy use of React hooks, so you'll need to be on React 16.8 or greater before attempting the upgrade...
Read more >Async React Components in React Router v4 - Medium
React Hot Loader 3 is the next compatible version. Sadly, it's incompatible with older React Router versions so long as you want async...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@filoxo I saw your codesandbox uses react-router-dom@4.4.0-beta.6, but, uses react-router@4.3.1.
I created a test repo here https://github.com/supasate/test-react-router-4.4.0 and it works well by using react-router and react-router-dom v4.4.0-beta.6. I saw the error appeared if I change one of that to 4.3.1.
However, even though my repo works well on my local machine, when I imported it to Codesandbox, it shows the same error. I guess, on Codesandbox, the
Link
component may importreact-router
from a different location of the mainreact-router
used in the repo, andLink
needs Context from react-router, so, it may get a different context.Please let me know if it still happens on your local machine and please provide a repo that I can clone and test on my machine.
https://reacttraining.com/blog/react-router-v5/#why-the-major-version-bump