Loading data in ReactRouter v7 - useLoaderData vs loaderData prop #12730
Unanswered
ondrejsevcik
asked this question in
Q&A
Replies: 1 comment 4 replies
-
AFAIK, the prop is preferred, but the hook is available so you can easily access the data deep in the component tree. Particularly, I think it's better to explicitly pass what you need to child components so they aren't coupled to the route. |
Beta Was this translation helpful? Give feedback.
4 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.
-
Hi, since upgrading to ReactRouter v7, I'm struggling to understand what's the preferred API to load data.
Previously, we've used
useLoaderData<typeof loader>()
hook. Now I see in some places in the documentation that the default route component accepts alsoloaderData
property.loaderData
as a prop (thecreateRoutesStub
does not accept component that definesloaderData
)?Thank you
Beta Was this translation helpful? Give feedback.
All reactions