Is it possible to get data returned from root.tsx loader in useRouteData? #3342
-
I am trying to pass around a "user" object around as global data to any components that needs it from the root.tsx file. Is it possible to get data returned from root.tsx loader in useRouteData? |
Beta Was this translation helpful? Give feedback.
Answered by
sergiodxa
May 30, 2022
Replies: 1 comment 2 replies
-
There's no useRouteData hook in Remix, the data returned by the root loader is available inside the root UI in useLoaderData and in any route through useMatches, specifically, the root is always the first match returned by useMatches, so you could do this: let [rootMatch] = useMatches() |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
machour
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's no useRouteData hook in Remix, the data returned by the root loader is available inside the root UI in useLoaderData and in any route through useMatches, specifically, the root is always the first match returned by useMatches, so you could do this: