I have seen my fair share of react tutorials, but any time that they talk about navigation using react-router, they only show the way using the Lin...
For further actions, you may consider blocking this person and/or reporting abuse
The last way - add utils/history, add this to BrowserRouter + trying to use this constant in redux action doesnt work. It changes url, but react-router don't render component
Looks, the problem because we create 2 instances of createHistory, Details - github.com/ReactTraining/react-rou...
Other ways works, thanks for article!
Glad you liked it. But you sure the last way is not working? I'm positive it was working when I wrote this post, I also linked my repo which has the code I wrote back then. I have used Router instead of BrowserRouter, as BrowserRouter comes with its own history
Amazing, it works when I tried to use Router! Thanks a lot !!
Programmatic navigation is useful for implementing complex navigation logic, such as redirecting users after form submissions, implementing multi-step forms, or navigating based on authentication status.
chimney repair
The article completely misses the hooks way (useRouter).
You should stick to the declerative way whenever you can. I think the article should endorse this to be complete.
Would checking for a Redux state and redirect on state change/value be a good way?
I updated my comment as it was bs :) For some reason I had reducers in my mind all along.
Any negative effects from redirecting using local state?
Thanks for the comment.
I'll try to update the article as soon as I can.
I've updated the post, would really appreciate if you check it out!
Good job!
So, react-router team is preferring
<Redirect to="/asd/" />
component over imperative stylehistory.push('/asd')
. But, sometimes is just easier to usehistory.push()
instead of rendering a redirect component. What's your thoughts?I think it's the same as using hooks and functional components over class based components.
Although it's recommended, it's better to just stick to whatever you and your team is more comfortable with and what makes more sense to you.
In the end writing code that actually works and which you can easily understand later to further iterate is more important.
Hi thanks for taking the time to post this but please I'm having an issue. I tried the first approach as recommended by you but the component I'm redirecting to is not displaying but the path in the URL will change. Any idea on how to fix that, please?
Note: If I redirect to the homepage it will work but to other paths is not.
Hi, maybe the problem is that you correctly or incorrectly, for example, entered the wrong address when importing, did not specify the wrong name and .. "Component" for
I mean:
I hope I helped.
Redirect
is removed inv6
- v6.0.0-alpha.3Thank you, useHistory() works great for me, so simple, brilliant!!
Thank you, useHistory Hook was exactly what I needed.
I like what you wrote here.
Good job.
Exelent bro, this helped me!
I like what you wrote here.
Great job. Check us out Telegram Crypto Groups
شركه تسليك مجاري بالدمام