-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Invariant violation after update to react-router 4.4.0 #6634
Comments
I just discovered the exact same problem with my code. |
That error should happen when you're using the Assuming that the |
It may be worth double checking your versions. I got surprised by an unintended upgraded to |
My problem could be that I have multiple versions of |
Using multiple versions of react-router and or react-router-dom will definitely cause issues like that. You can't use react-router 4.3 with react-router-dom 4.4 or vice versa. (Edit: writing it out like that: Why isn't that considered a breaking change?) Your build process might also cause some issues in that regard. Particularly if you have imports pointing at both "react-router" and "react-router-dom" in your codebase. Compare with #6581. |
I have react-router and react-router-dom in my project and two packages used, npm update makes this dependency updated everywhere but I think that problem actually in built packages, those bundles built on previous version therefore indeed it can be version conflict. |
React router dom (v4.3.1) requires react-router v4.4.0. But in the main package react-router v is 4.3.1. So, my solution is to change version of react-router in shrinkwrap to 4.3.1. Please check dependency versions |
I fixed this by ensuring I imported withRouter from 'react-router-dom' everywhere in my code. Before I had been importing from 'react-router' in some places and 'react-router-dom' in others. |
I tried to search the changelog, but looks the doc haven't catch up?! |
Link is a child of BrowserRouter in my app, as you can see from the second error. Using react-router and react-router-dom 4.4.0, react and react-dom 16.8.4 |
npm list react-router react-router-dom and then, if by chance you reside on *nix cd mySource; grep -rnw . -e 'withRouter' |
I'm pretty sure this is a duplicate of #6630. Your Let's follow up there. |
I'm getting this error when I import a component from one of our internal packages that contains a |
I am seeing the same thing as @mccambridge; Upgrading to |
Same as @mccambridge experience same kind of error, after updating both packages and main project react-router and react-router-dom version to 5.0.0. Returning back to 4.3.1 make things working. |
@mccambridge @alexanderturinske @Cherviakov I've fixed it by deleting |
@taschetto you using ReactRotuer in your main project and in written by you packages, which you use in your project? It is working normally in single project, but when you add packages then seems somehting goes wrong between reactRouterv.@5.0.0 in main project and in package. This is why in our case we have to fallback to v4.3.1 |
I still had this occurring on v5, had to downgrade to 4.3.1 to get it working again as well. |
I am having this issue after updating to |
Ditto here, upgrading from 4.3.1 to 5.0.0 without making any changes to the project caused: I'm using |
I ended up using npm locally instead of submodules and then added |
For everyone, who are trying to use the exact versions (4.3.1) as a workaround and still have their builds failing - please make sure you are NOT using
in my *package.json`, I've tried both options:
|
@mccambridge I'm having the same issue when upgrading from 4.3.1 to 5.0.1 when a common components package is imported that has a component that contains a I opened #6769 |
Works for me, thanks |
Version
4.4.0
Steps to reproduce
webpack build
run with wepback-dev-server
Get Invariant violation: cannot use Route or wirhRouter() outside of Router
Expected Behavior
No error, as nothing else changed but version of react-router and react-router-dom packages
Actual Behavior
The text was updated successfully, but these errors were encountered: