Data Loading and Local Pagination
I have a route that fetch a dataset.
I want to do local pagination.
Is it possible to have child routes sharing parent query?
this is base route
this is child route
this is the view that both share
this works for
'/images'
route but not for 'images/image-id'
because the Route does not match.
what's the best approach to do that?
do I just have to add the same data query to the '/images/$id'
route without worrying about the double query?
or there is a more efficient way to handle these use cases?1 Reply
generous-apricot•4mo ago
You can access router data from an arbitrary route (see here https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#consuming-data-from-loaders), but if you wan tot have more control over caching and easier access to the data, I would suggest to go the react query route to decouple the data loading and caching from the routes.
Data Loading | TanStack Router React Docs
Data loading is a common concern for web applications and is related to routing. When loading a page for your app, it's ideal if all of the page's async requirements are fetched and fulfilled as early...