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•4mo 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•4mo 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-salmonOP•4mo ago
Thanks guys!