I'm working with React Router V5.
I have implemented my application routes.
- HomeComponent for all users
- LoginComponent only for not logged in users.
My issue is when i'm logged in and i go into /login then i stuck on blank page. I want achieve redirection into home component. Login component should be only available
Could you tell me what is wrong with my routes?
export const AppRoutes = () => {
const { currentUser } = useAuth();
return (
<Switch>
{!currentUser.isLoggedIn && <Route exact path='/login' component={Login} />}
<Layout>
<Switch>
<Route exact path='/' component={Home} />
<Redirect to='/' />
</Switch>
</Layout>
</Switch>