T
TanStack7mo ago
noble-gold

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
national-gold
national-gold7mo 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)
metropolitan-bronze
metropolitan-bronze7mo 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
noble-gold
noble-goldOP7mo ago
Thanks guys!

Did you find this page helpful?