Replies: 1 comment 1 reply
-
I am trying to achieve the same, really similar use case for me. Another thing I've tried is to use the loader in the root route and access to the loader data as follows It would be helpful having a way to access to the root route, something like: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So my app layout looks like this:
/
/items/$id
/otherItems/$id
In the
/
route - I would like to load "configuration".In
/items/$id
and/otherItems/$id
I would like to follow this example: https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#a-more-realistic-example-using-tanstack-queryIssue I have - I need that configuration from the root route within loader function. So, I look into the context.
And what I found - is either you create that context at the app root (https://tanstack.com/router/latest/docs/framework/react/guide/router-context#using-the-router-context),
or you return data in the
beforeLoad
callback (https://tanstack.com/router/latest/docs/framework/react/guide/router-context#modifying-the-router-context).I did this - kinda works. But I am not satisfied with this 😞 preload doesn't display pendingComponent while it is loading. It just blocks the app.
If I put the root data loading into loader() - I get the pendingComponent, but I lose that values in router context, and I cannot use them in the child route loader()'s
This makes the router context kind of lackluster..
In my opinion -
if I have a route
/items/$id
that loads data for $id -/items/$id/whatever
should also get that loaded data without any friction.Beta Was this translation helpful? Give feedback.
All reactions