Given this example from the react router dom docs page:
createBrowserRouter([
{
path: "/",
loader: () => fetchUser(),
element: <Root />,
id: "root",
children: [
{
path: "jobs/:jobId",
loader: loadJob,
element: <JobListing />,
},
],
},
]);
Is there a way to access the loaded data from the root path (provided by the fetchUser
function) in the loadJob
loader function of the child path? as loadJob
is just a function and not a react hook, I cannot use useRouteLoaderData("root")
there.