T
TanStack4mo ago
extended-salmon

How to wait upper loaders

Is it possible for a sub-route loader to wait for the loaders in the upper trees? Ex: /users -> has loader /users/tanstack -> has loader /users/tanstack/configs -> has loader /users/tanstack/configs depends on the other 2 loaders.
3 Replies
metropolitan-bronze
metropolitan-bronze4mo ago
No, loaders are parallel. Maybe you could use beforeLoad which isn't parallel. Or maybe if you use tanstack/query, just do the query multiple times (they'll be deduplicated anyway, so it's free)
passive-yellow
passive-yellow4mo ago
you can access the parentMatchPromise in the loader and await that, then you you can acces the parent's loader data. but the easier way would just to put the data loading into beforeLoad of those routes, since beforeLoad methods already execute serially
extended-salmon
extended-salmonOP4mo ago
Thanks guys!

Did you find this page helpful?