6.4 - Where to put our AppProviders? #9424
Unanswered
kevinfairclough
asked this question in
Q&A
Replies: 2 comments 3 replies
-
I think your question is related to #9327 |
Beta Was this translation helpful? Give feedback.
1 reply
-
If the provider doesn't need router/data information, you can put it on the outside: <SomeProvider>
<RouterProvider router={router} />
</SomeProvider> Or if the context needs routing/data information, put it in the root route element. const router createBrowserRouter([
path: '/',
element: <Root />
children: [/* ... */]
]);
function Root() {
const data = useLoaderData();
return (
<SomeProvider data={data}>
<Outlet />
</SomeProvider>
)
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi
We have quite a few AppProviders where do we put them ? Around the RouterProvider or inside the RouterProvider ?
And how do we access data from contexts in loaders ?
Thanks
Kevin
Beta Was this translation helpful? Give feedback.
All reactions