Page is not rendering after history.push('/path')
See original GitHub issueHi,
I have a problem using history v. 5 with react-router-dom. When I call function history.push(‘/cart’) it sends me to the correct page, but it doesn’t show the content.
If I use history version: “4.10.1”, it works perfectly.
Am I doing something wrong ?
This is my history.js file
import { createBrowserHistory } from 'history';
const history = createBrowserHistory();
export default history;
And this is my app.js
import React from 'react';
// import { Router } from 'react-router-dom';
import { Router } from 'react-router';
import { Provider } from 'react-redux';
import { ToastContainer } from 'react-toastify';
import store from './store/index';
import history from './services/history';
import Routes from './routes';
import GlobalStyle from './styles/global';
import Header from './components/Header';
function App() {
return (
<Provider store={store}>
<Router history={history} >
<Header />
<Routes />
<GlobalStyle />
<ToastContainer autoClose={3000} />
</Router>
</Provider>
);
}
export default App;
Issue Analytics
- State:
- Created 3 years ago
- Reactions:27
- Comments:13
Top Results From Across the Web
Component is not getting rendered after history.push()
components/Home.js (a component like Home is aware of routing and has the history object already passed in via the <Route path="/" ...
Read more >history.push not rendering component in Router #7415 - GitHub
I experienced same issue now. The URL changed to the supposed history.push("/myURL"), however, the page is not rendering the component. Any ...
Read more >history.push is only changing the URL, not rendering component
push or props.history.push from any component, you may face the issue of not rendering the component while changing the URL. You can fix...
Read more >History - React Router: Declarative Routing for React.js
The history object is mutable. Therefore it is recommended to access the location from the render props of <Route> , not from history.location...
Read more >props.history.push is updating url but not re rendering - Reddit
Check if the situation will change with using `useHistory` hook, you won't be needing the withRouter HOC. Recheck if you don't have nested ......
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
I’m running into the same. Here’s a self contained example: https://codesandbox.io/embed/crazy-dirac-04nil?fontsize=14&hidenavigation=1&theme=dark
Downgrading this example to
history@4.10.1
fixes the issue.I have the same
You made my entire day 😃