I have webapp written using React and React Router.
Are there any pros/cons of using window.location.href to redirect vs using the component provided via react-router?
Use history.push('/page-name')
if you don't want the browser window to be reloaded, or window.location.href if you want to reload it. Usually when using the React Router the default behavior is using the history.push (this.props.history.push('/page-name'
) to be more specific, as the rest of the navigation through the application is already using React Route's <Link>
, which has the same effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With