TanStackT
TanStack2mo ago
3 replies
primary-violet

Passing data to child routes from loader

Hello everyone. I've been tinkering around with
beforeLoad
and loader for the past few days.

essentially what I have is a shelf route which has a loader to fetch data such as meetings. This shelf route has 2 child route which are shelf/calendar and shelf/actions/(schedule - reschedule - cancel).

I am fetching this data inside route.tsx of shelf and having issues trying to pass it off to it's child routes calendar and actions.

I have tried using
beforeLoad
to fetch data and then pass it off. This works as I can access the context in the child route and get my data but does not work for loader

I am so used to passing properties to Outlet but tanstack router Outlet works very differently from the react router.

If someone could point me in the right direction or reference the functions i should be using. I would be very thankful

- shelf ( directory )

-- actions ( directory )
--- cancel.tsx
--- reschedule.tsx
--- schedule.tsx
--- route.tsx

-- calendar.tsx
-- route.tsx ( fetches meetings here )
Was this page helpful?