T
TanStack3y ago
correct-apricot

Layout and loader in same path

If a layoutComponent and loader is defined in the same route then the layout is currently not rendered until the loader is completed. Is it possible to configure the the loader to execute "inside" the layoutComponent and use the route's pendingComponent? The fix/workaround for this currently seems to be to add a child route to the layout route that does the loading. Unfortunately this creates a lot of extra configuration. We have two nested layouts, a "root" and then a section specific layout. To load data for each level we need to add a "loader" route under each layout. This leaves us with a structure like root > layout > root-loader > projects > layout > projects-loader > projects-index. If the loaders were run inside suspense context created for the current route it would negate the need for the extra routes which would simplify our structure to root > layout > projects > projects-index.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?