#Is the data pulled from `useRouteLoaderData` in a child guaranteed to be there?

1 messages · Page 1 of 1 (latest)

eternal geyser
#

If I am calling useRouteLoaderData in a child route to get a list pulled in parent loader. Is there a guarantee the parent loader is resolved (if not using Async) before the child tries to fetch that data?

#

useLoaderData has that guarantee. Just want to know if the same applies to useRouteLoaderData or if I need to account for a "it's not resolved yet" state during the render.

sour vortex
#

If it's a parent or child route, the data is guaranteed to be there

#

If it's a sibling route you need to account for undefined

eternal geyser
#

Awesome, thank you Tom! Do know if useMatches has the same constraint?

sour vortex
#

It will do, yep