-
Notifications
You must be signed in to change notification settings - Fork 961
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
React router not working after upgrading to v 5 #804
Comments
we've recognized same behaviour. url is updated after history.push but navigation is not working anymore with react-router, also no error in the console |
I am facing the same issue. It looks like there is some breaking changes in the newest version "5.0.0" of history package. For now, we can change its version to "4.10.1" which works for me. |
same issue. |
You probably have to update to the react router v6 alpha as well, as the v5 is explicity specifying v4 history in its dependencies. More likely than not, you will have two (conflicting) history deps if you are still using react-router 5. |
This is probably a duplicate of #803 |
@zerone2 you saved my sanity and my hair. Using:
Working for me! |
PrivateRoutes seem to not work in v5. |
same thing, we are using hash router and |
Signed-off-by: Jaid <jaid.jsx@gmail.com>
Any news about this?? |
So this is the reason why history.push() is not working, im using the version 5. okay got it, removing the history.push() maybe a bad idea on future release. i'll stick to version 4. Thanks |
I've just spent a few hours pulling my hair and trying to diagnose why my routes weren't matching. Thank you! |
Yes changing to @4.10.1 solves the problem, been pulling my hair for quite some hours too! |
But if you use callback in history.block() then v4 doesn't help! |
After spending sufficient time where I am wrong, I checkout my old code which was working. Yes, there is a reason why things are called "bleeding edge"... |
I was trying to figure out why the history it wasn't passed for my components, after the comments here I did the downgrade to history@4.10.1 and everything is work now. Thanks, guys 👏 |
Hi! Is there any other solution besides downgrading to v-4? |
Thats' the solution xD |
You can also upgrade react-router to 6 (alpha) because react-router 5.2 is using dependencies from history 4 and that is causing conflict issues. But personally, I would suggest to downgrade the history lib itself until react-router 6 is in a stable state. |
May be router should check if history 5 version and do throw |
Same problem here, history v5 is incompatible with the current latest react-router. |
Wasted an entire day on this. So frustrating. Will update as soon as I test different versions. How was this problem traced to the history package? |
I also came across this issue. Was solved by downgrading
|
Jesus, guys, I just lost 2 days on desperately trying to figure out what went wrong in my project. Without any errors in the console or otherwise, the routing just stopped working, it drove me crazy... Lucky that I have just a few deps in my package.json so it didnt take ages to drill down to the faulty one... Hope it will be fixed soon!
In my lowest moment I just started downgrading and upgrading back again all my deps one by one to catch which one causes the change in my app's behaviour... |
I also have issues with history 5. Decided to downgrade to ^4. |
Upgrading history to v5.0.1 and react-router-dom to v6.0.0-beta.1 solved the issue for us. |
React Router 5 has a dependency on history v4, not v5. You should use history v4 with React Router 4/5.
You shouldn't ever use For a React Router v5 project, if you want to install
|
history is installed separately and used alongside react-router when there's a need to create history before instantiating BrowserRouter. For that purpose I propose react-router expose it's own createHistory methods (which could simply wrap the history.js api) so we wouldn't have to manually keep an eye on the versions - it's tedious and wastes our time |
but link is still not working for me |
Yes Instead of useHistory we can use "useNavigate" for the upgraded version Eg: import {useNavigate} from "react-router-dom"; In method: navigate("/", {replace: true}) |
The useNavigate is not working in class component |
Hooks don't work in class components, they are meant to be used in functional components. |
I used the connected react router in my development, but when I update the routing data with Redux, I am prompted with the pathname error. How can I solve it
|
in localhost app is runing good |
Hello, we've upgraded the history version to 5.0.0 without knowing it because it was set to "latest" in package.json.
What we have found is that the url in the browser gets correctly updated using "history.push()" (with both BrowserHistory and HashHistory) but the navigation is not tirggered anymore.
Also, using react-router-dom Link component, the path gets built wrong, skipping the first "/" after the base path.
Switching back to 4.10.1 fixed the issues for us.
The text was updated successfully, but these errors were encountered: