Hello, struggling with routing a user based on a user_metadata value. We have the following:
<Switch>
<PrivateRoute
path="/"
name="Home"
component={props => <DefaultLayout {...props} />}
/>
</Switch>
By this time, the user is authenticated but for some reason we don’t have the user object itself yet. Leveraging the “user” custom hook from the SPA SDK is possible but the app renders the route before the user hook provides the user.
What we’d like is something something like
const { user, getUser, isAuthenticated } = useAuth0();
const userExperience = (userType) => {
switch(userType) {
case 'typeOne':
return <TypeOneLayout {...props} />;
}
...
}
<Switch>
<PrivateRoute
path="/"
name="Home"
component={props => userExperience(user["blah_var_on_meta"])}
/>
</Switch>
But this isn’t working as expected. Basically 100% of the time it executes the default fallback switch because user isn’t available yet.