I am trying to find out the name of the component rendered within the Outlet
component in order to further decide whether a user has permissions to view it.
My Root component:
import {
Outlet,
useNavigation,
useOutlet
} from "react-router-dom";
import { OrbitProgress } from 'react-loading-indicators';
import { StoreContext } from "./store";
const Root = () => {
const navigation = useNavigation();
const outletData = useOutlet();
console.log(outletData);
return (
<>
{navigation.state === 'loading' &&
<div className="loading">
<OrbitProgress
color="#0d6efd"
size="medium"
text=""
textColor=""
/>
</div>
}
<Outlet context={StoreContext} />
</>
);
}
I tried using useOutlet
hook, but it provides an object with a bunch of nested objects, however I couldn’t find the name of the child component rendered. Is it possible to know the child component name?