question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatible with react-router v4.4.0-beta.6

See original GitHub issue

I 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 Links and Switches 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:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
supasatecommented, Jan 13, 2019

@filoxo I saw your codesandbox uses react-router-dom@4.4.0-beta.6, but, uses react-router@4.3.1.

image

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 import react-router from a different location of the main react-router used in the repo, and Link 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found