this.props.history is not available in componentWillReceiveProps()
See original GitHub issueI am trying to access
this.props.history
inside componentWillReceiveProps() but it is giving me undefined.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
React-router v4 this.props.history.push(...) not working
So I came to this question hoping for an answer but to no avail. I have used const { history } = this.props;...
Read more >[Solved]-ReactJs this.props.history.push() is not working-Reactjs
Coding example for the question ReactJs this.props.history.push() is not working-Reactjs.
Read more >location - React Router: Declarative Routing for React.js
location. Locations represent where the app is now, where you want it to go, or even where it was. It looks like this:...
Read more >Strict Mode - React
Strict mode checks are run in development mode only; they do not impact the production ... componentWillReceiveProps (or UNSAFE_componentWillReceiveProps ) ...
Read more >ReactJS UNSAFE_componentWillReceiveProps() Method
The componentWillReceiveProps() is invoked before our mounted React component receives new props. It is called during the updating phase of ...
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 FreeTop 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
Top GitHub Comments
Figured it out. Preact
preact-router
gives route(${PATH}
) to navigate.React
this.props.history
is available throughreact-router-dom
by importing it and then wrapping exported component withwithRouter
to navigate.Thanks @marvinhagemeister
Can you show us the code where you’ll pass
history
to the component? It should work the same way in preact as it does in react. There is very likely something else going on that’s not related to the underlying framework but has to do with app code. Can you make a simple example in https://codesandbox.io/ where the issue can be reproduced?