I am stuck in strange error. I am trying to protect my client side route. I have this code

Now, i go to login page, click login, it comes back to login page . But, when i dont protect this route and I have it unprotected

It works perfectly and after login, i go to this Apphome component.

I am using react.js and auth0 . What’s the issue here?

Thanks in advance

<Router history={history} component={App}>
      <div>


        <Route path="/login" render={(props) => <Login auth={auth} {...props} />} />
        
        <Route path="/apphome" render={(props) => (
              !auth.isAuthenticated() ? (
                <Redirect to="/login"/>
              ) : (
                <Apphome auth={auth} {...props} />
              )
            )} />
        <Route path="/contacts" exact component ={Contacts} />
        <Route path="/mytodo" exact component ={Mytodo} />
        <Route path="/favorites" exact component ={Favorites} />
        <Route path="/mention" exact component ={Mention} />
        <Route path="/profile" exact component ={Profile} />
        <Route path="/buy" exact component ={Buy} />
        <Route path="/success" exact component ={Success} />
        <Route path="/cancel" exact component ={Cancel} />

      </div>
    </Router>

I see this code in documentation

<Route path="/ping" render={(props) => (
  !auth.isAuthenticated() ? (
    <Redirect to="/home"/>
  ) : (
    <Ping auth={auth} {...props} />
  )
)} />

Now, I have seperate login page with login route.

  <Route path="/apphome" render={(props) => (
              !auth.isAuthenticated() ? (
                <Redirect to="/login"/>
              ) : (
                <Apphome auth={auth} {...props} />
              )
            )} />

Now, if i try to open /apphome . It works correctly , unauthenticated user goes to login component. However, if i try to login, after login I go back to login page.

In my local storage, I have this

key . - com.auth0.auth.rRudUuEGZ2q3UEe3pH8aFOMwg-7va9fU

value - {“nonce”:“BE.Xm4eforMn2wPSgDle1wx_nEYCVPV9”,“state”:“rRudUuEGZ2q3UEe3pH8aFOMwg-7va9fU”}

Can someone tell me, whats the error here?