#How can I access root data?

18 messages · Page 1 of 1 (latest)

oak oracle
#

Which I’ve defined in root.data.ts

dark glade
#

Might need more detail, can you just export and import it where needed? What kind of data

oak oracle
#

@dark glade I've found that, in StartClient, it's checking for root.data.ts and if it exports default function for fetching data, it fetches it, but I can't find a way to access that data, useRouteData doesn't return it

oak oracle
#

@plain stone @hallow scroll maybe you know something about this? sorry for tagging

#

this is from solid-start/entry-client/StartClient.tsx

#

that dataFn is fed to StartRouter

#

#legacy-help message

#

const rootData = useData(0); this useData is no longer exported.

@steep wren maybe you know up to date way to access root data

steep wren
oak oracle
#

maybe @wet compass knows how it can be used

wet compass
#

Right.. it is probably about where it is used. Technically useRouteData should return it, but the read might need to happen lower down... it also feeds into the data property of child routeData's

oak oracle
wet compass
#

It gets passed through the routeData itself.. like you need to re-send it..

export const routeData = ({ data }) => 
wet compass
#

If there is no routeData for the route then it should just use that instead

oak oracle
wet compass
#

Where is the provider?

#

My gut here is if you have global context anyway there isn't much advantage in using the root data