Open cristi-lng opened 3 months ago
If I understand correctly no component should be rendered until all loaders are finished. Is this still true?
a route will render as soon as its loaders are finished. So the root route will render as soon as the loaders of the root route are done. It will not wait for loaders of child routes.
there is no aggregation of loaders
Ok, but if this is the case why isn't the layout route from my example rendered as well? Because it doesn't have any loaders.
Also, if for example, the loader from a child route finishes before the one from the parent I still suspect that the child won't be rendered until the parent loader is finished.
I believe that the behaviour changed somehow because if we run with the old version of the router (1.22.9) it waits for all the loaders before rendering.
This is mainly because of our homemade transition framework that "holds" state updates to the rendered state until everything is ready. Sounds like the root route is escaping that framework. I'll work on this now.
More information here that needs to be considered, specifically for client-side SPAs:
Currently:
Considerations
@tannerlinsley Thanks for the detailed answer.
More info about our approach:
index.html
even before the js is loadedThis is the way I thought that the route segments will load:
Wouldn't this behaviour allow enough flexibility? To choose when to wait for everything or display some pieces earlly? In this case, it wouldn't be limited only to the root route.
@tannerlinsley Thanks for the information on this.
I am currently experiencing the same while developing an SPA. My two cents:
beforeLoad
to do exactly what it suggests: do all of this before rendering the route - this way I can be sure my component has what it needsbeforeLoad
depending on where it's used (root vs sub-route / SPA vs SSR) could be confusing and the type of context
properties inside the root route would need to change, since they could be not loaded yetbeforeLoad
finished a possible long running request within the root route, I would not use beforeLoad
but handle the request on a deeper component level with it's own loading animation. This way the rest of the page is not blocked from renderingThanks for all the work on these amazing packages!
@Nils-Kolvenbach In this ticket I was specifically referring to the loader
and not the beforeLoad
.
In our tests the beforeLoad
works as expected. At least in SPA mode. It waits until everything is ready an works in serial fashion.
Do you see something different here? If so, do you have an example?
Ah, thanks for clarification! After an update to the latest version (1.45.2 -> 1.49.1) and the corresponding router plugin and devtools everything works as expected for me.
I have updated the example app to the latest version of the router (1.51.0) and the issue is still there.
https://stackblitz.com/edit/tanstack-router-vkppeu?file=src%2Fmain.tsx
Describe the bug
It seems that the root route component is rendered before all the loaders finished their work.
If I understand correctly no component should be rendered until all loaders are finished. Is this still true?
When I test with a default pending component the behaviour seems to be correct. So, the problem is only when there is no pending component.
Your Example Website or App
https://stackblitz.com/edit/tanstack-router-vkppeu?file=src%2Fmain.tsx
Steps to Reproduce the Bug or Issue
defaultPendingComponent
to test in pending modeExpected behavior
If no pending is used, I am expecting to see everything rendered after the loaders are finished.
Screenshots or Videos
No response
Platform
Additional context
No response