You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the route loader data are only fetched when initialized and loaded under the same scope, and when we go though the components and define a new <Routes> in a particular component and then define the <Route > inside, loader data will stop propagating, nor give you the loader data of that route.
For example, I have the following code where I initialize the RouterProvider under the QueryClientProvider in the root of the application:
If I use the hook useLoaderData and log the result in the components above it will give the right data. However, when I go inside the component <Login /> and define the following routes under <Routes />:
then the useLoaderData in the SignInStep2 component will always return undefined and lose track.
Should we always define the routes in one createBrowserRouter section for the entire application to use the loader feature, or is there another way to accomplish that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I noticed that the route loader data are only fetched when initialized and loaded under the same scope, and when we go though the components and define a new
<Routes>
in a particular component and then define the<Route >
inside, loader data will stop propagating, nor give you the loader data of that route.For example, I have the following code where I initialize the
RouterProvider
under theQueryClientProvider
in the root of the application:the
root_router
defines the following routes:If I use the hook
useLoaderData
and log the result in the components above it will give the right data. However, when I go inside the component<Login />
and define the following routes under<Routes />
:// login.tsx
then the
useLoaderData
in theSignInStep2
component will always return undefined and lose track.Should we always define the routes in one
createBrowserRouter
section for the entire application to use the loader feature, or is there another way to accomplish that?Beta Was this translation helpful? Give feedback.
All reactions