
I was in a middle of a project, and I didn't used React for a while. I had to solve the situation: I had got a component, which was embeded deeply ...
For further actions, you may consider blocking this person and/or reporting abuse
this was such a life saver! Do you mind explaining why
this.props.history.push("/home")
might result in undefined but this would work?I think it has something to do with this line--With its help, you can pass the whole history object to your component as properties.-- but am not 100% sure.
Fantastic! This finally makes some sense to me. I spent hours trying to help someone that using we children under it vs component= and I couldn't figure out why this.props.history.push() wasn't available!!! I only/ever use component= so never saw this other approach (embedded children) and didn't suspect it.
So, in your app, if at some point you want to re-direct the user (in javascript, not a tag) to a new location, what's the best way? I do not think it is window.location= because that's a page reset, right? And if you can't get to the router history, WHAT do you do??
I know you said this a few months ago, but in case you were still wondering haha.. the history object actually exists on the window object itself in plain old vanilla JS.
This was really helpful. Thanks
Thank you! You saved me from losing my mind over router redirect :) 👍
You saved my asss. thanks a lot :)
Thanks a lot Krisztian for this!
It is a pity that I just found this post. This would have saved for me a day of struggle and search for solutions for my react project.😄
Next time you can solve the problem in minutes!😃👍
Valeu Mano
Muito obrigado!
I was looking for this for a long time. Lots and lots of worakarounds and the solution was that simple. Thank you for this!
Thanks! This helped me with a problem! Appreciate it!
Just one word 'Amazing' !
With this one,
i was able to fix an issue caused by referencing the component in routes using "render" not "component" prop.
Thanks a lot!
Thank you for this article, I'm not sure I understand this solution but I knew the reason it was undefined but not how to solve it.