Lazy load entire router tree
Is there an easy way of lazy loading an entire router tree at once? i have 3 big routes which contain a lot of nested routes, my objective is when a user accesses route1, it loads all of its children routes and its components
4 Replies
extended-salmon•3y ago
You cannot lazy load routes, but you can lazy load their components and onLoad logic
adverse-sapphire•2y ago
I had the exact same question. Is it still impossible to lazy load a route and all its children simultaneously?
like-gold•2y ago
yes, but what's the problem of loading the routes and "only" lazy load the components/loader?
extended-salmon•2y ago
I think you might be referring to something like “deep preloading” where a parent preload would automatically trigger preloads on child route components
And while that may be theoretically possible, you still wouldn’t be able to preload child loaders automatically since they may depend on search parameters or context to run.
All in all, I don’t think that is a very good pattern. Keeping things granular and based on usage will cover almost all pre-fetching and preloading use cases and help you avoid over fetching