I have an app using react-router-v4. I have a matching page which, unless you are logged in, you can't access. When a user is not logged in and tries to go to /match they get redirected to /login. My issue is that when the user is redirected to /login the URL stays as /match. This is causing issues elsewhere in my code. How can I get React-Router to update the URL when the user is redirected to /login? I am redirecting the page from my switch inside App.js. Here is an example of what my code looks like:
<Route
path='/match'
component= {
() => {
if (this.state.auth) return <HomePage />;
else return <LoginPage />;
}
}
/>
TL;DR
How can I get the URL to change to /login if the user isn't logged in when trying to access /match.