i'm having some trouble with my react/redux app. 
I've successfully implimented login functionality - that redirects to the home page once logged in.

The issue I have is if I go the URL, and type in /login. The login screen displays for a second, then redirects to the home page. How can I make it redirect straight away?

Note: The only way i've been able to make it work is instead of checking the state isAuthenticated, check localStorage for a token, then redirecting.

```
const App = () => {
  useEffect(() => {
    if (localStorage.token) {
      store.dispatch(loadUser());
    }
  });

  return (
    <Provider store={store}>
      <Router>
        <div id='js-scroll'>
          <Switch>
            <Route exact path='/' component={Home} />
            <Route exact path='/register' component={Register} />
            <Route exact path='/login' component={Login} />
          </Switch>
        </div>
      </Router>
    </Provider>
  );
};

```

```
const Login = ({ login, isAuthenticated }) => {
  if (isAuthenticated) {
    return <Redirect to='/' />;
  }

  return ( ... )

const mapStateToProps = state => ({
  isAuthenticated: state.authReducer.isAuthenticated
});

export default connect(
  mapStateToProps,
  { login }
)(Login);

```