How to get root data client side ? useMatches or useRouteLoaderData ??? #10044
Unanswered
theocerutti
asked this question in
Q&A
Replies: 1 comment
-
Both should be fine as I'd recommend exporting the first function from the // root.tsx
export const useRootLoaderData = () => {
const rootData = useRouteLoaderData<typeof loader>('root');
return rootData;
}; // routes/some-route.tsx
import { useRootLoaderData } from '~/root'; |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey!
I've a question what is the more reliable to get root data between:
useRouteLoaderData
useMatches
Beta Was this translation helpful? Give feedback.
All reactions