Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRan Wang
Full Stack JavaScript Techdegree Graduate 32,191 PointsWhy use history.push() instead of redirect?
In this video, teacher used history.push() in stead of redirect method which seems a bit strange for me, in my understanding, history by its definition, should serve only to store historical navigates, the feature to navigate to a new page should be the responsibility for redirect method.
Am I wrong about this?
Thanks.
1 Answer
A R
12,834 PointsHey, I was wondering that myself, too. It's been a while since this was posted but in case anyone is following links from the video...
While I don't know the technical aspects of why it's the chosen way of doing things, apparently it's part of using BrowserRouter, and there are alternatives like HashRouter that uses a URL hash instead.
To read more, https://stackoverflow.com/questions/51974369/hashrouter-vs-browserrouter
G H Mahimaanvita
16,234 PointsG H Mahimaanvita
16,234 PointsYeah, I have that doubt too