I have protected route named <LoggedRoutes/>
that should redirect and render my <Onboarding/>
component if the user has not completed his onboarding. But the component is not rendering whereas my <Login/>
component is rendering if I'm not logged. I don't get why. Note that the redirect is effective because when I try to get to /edit
for example, I'm redirected to /onboarding
.
Any ideas why my <Onboarding/>
component is not rendering ? Thanks in advance! Below is the code :
const LoggedRoutes = ({ component: RouteComponent, ...rest }) => {
const { currentUser } = useContext(AuthContext);
const onboarding = false;
return (
<Route
{...rest}
render={routeProps =>
!!currentUser && onboarding ? (
<RouteComponent {...routeProps} />
) : !!currentUser && !onboarding ? (
<Redirect to={"/onboarding"} />
) : (
<Redirect to={"/login"} />
)
}
/>
);
};
Thanks in advance!