Auth0 SPA SDK w/ React > Routing User by Type/Role

Howdy folks, so we’ve made some good progress so far but we’ve found ourselves blocked on routing users by role.

Login happens flawlessly and we are wanting to load customer layout components based on role type. The problem is, we aren’t getting the role fast enough. In the below, we eventually get the proper role but not before “renderSwitch” has already executed and defaulted to TypeOne in the switch case.

We’ve tried a number of different ways to handle this, first attempt was just “{user && user[“https://blahblah/role”] && …” > render but again, since this was firing immediately (w/ user undefined) it would fail.

What is strange is by this time, they are authenticated… so why in the heck wouldn’t we have immediate access to “const { user } = useAuth0();” ??

Stumped. Any suggestions?

Thanks in advance!!!

const App = props => {
const { user } = useAuth0();

const renderSwitch = (param) => {
switch(param) {
case ‘TypeOne’:
return <TypeOne {…props} />;
case ‘TypeTwo’:
return <TypeTwo {…props} />;
return <TypeOne {…props} />;

return (

<React.Suspense fallback={loading()}>

component={props => renderSwitch(user[“https://blahblah/role”])}