I'm having a ton of difficulty finding the answer. Right now all my
<Route exact path='/' render={()=><Redirect to='/dashboard'/>}/>
does is change the url to ".../dashboard", but it doesn't refresh the page so that the component loads, only when I hit refresh does my component load.
How can I get <Redirect ... /> to refresh the page after redirect?
I have had success with window.location.reload(), but I don't know how to put it in. I've also tried adding <Redirect push to=.../> without luck.
setup a switch route and a Redirect component
<Switch>
<Redirect from='/' to='/dashboard'/>
<Route path='/dashboard' render={(props) => (
auth.isAuthenticated === true
? <Component {...props} />
: <Redirect to='/login' />
)}
/>
</Switch>
More on the docs
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