DEV Community


Discussion on: Programmatic Navigation in React using react-router

webcoderkz profile image
Alexander Kim

So, react-router team is preferring <Redirect to="/asd/" /> component over imperative style history.push('/asd'). But, sometimes is just easier to use history.push() instead of rendering a redirect component. What's your thoughts?

projectescape profile image
Aniket Author

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.