#Question about loader / beforeLoading

2 messages · Page 1 of 1 (latest)

drowsy hedge
#

So what do I do in this type of case :

/$id
  route.tsx    <-- Need to fetch some data about related to the $id
  path-a.tsx
  path-b.tsx.  <-- Need to access the `route.tsx` data in its own `loader()`.

If I put my dataloading in the beforeLoad of the route.tx, I can pass it in the context and all is fine, the children paths have assess to it. But, the beforeLoad seems to refetch every navigation, but I don't want to do that since the information only changes when the $id changes.

I know that the loader() are run all at the same time for the routes so the children cannot access the data of the parent in their loader(), so what should I do ?

craggy ibex
#

load the data in beforeLoad using tanstack query and cache it using that