#Do we have any way to use root context or routing context in react-router loader and react
1 messages · Page 1 of 1 (latest)
no, RR loaders run outside React so there's no way to access React's context there
in a future RR release they will add a context parameter to RouterProvider so in that case you could do something like this
<AuthProvider>
{auth => <RouterProvider router={router} context={{ auth }} />}
</AuthProvider>
and in your loaders will get this context object as an argument of the loader along request and params, but this is not released yet
my recommendation, even once RouterProvider accepts this context object, is to avoid keeping things like auth as a React state
I'm using RouterProvider in RR v7, the context isn't declared in RouterProvider 