14 Replies
Might need more detail, can you just export and import it where needed? What kind of data
@maxoucsgo 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
@thetarnav @lxsmnsyc maybe you know something about this? sorry for tagging
this is from
solid-start/entry-client/StartClient.tsx
that dataFn is fed to StartRouter
https://discord.com/channels/722131463138705510/722349143024205824/885899935290101823
const rootData = useData(0);
this useData is no longer exported.
@davedbase maybe you know up to date way to access root dataI’m not sure, perhaps the router mechanic changed and I have no idea
maybe @ryansolid knows how it can be used
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'sthanks for the response. I've tried using useRouteData almost everywhere, can't find that root data anywhere
It gets passed through the routeData itself.. like you need to re-send it..
got it, thanks!
If there is no routeData for the route then it should just use that instead
What I was thinking was, that I have some external JSON for i18n, which holds language data. So I thought, I would've fetched it with root.data.ts and then pass it to i18n's provider via useRouteData.
Where is the provider?
My gut here is if you have global context anyway there isn't much advantage in using the root data
Like this is just a way to hoist stuff out it has no other special properties. You can fetch data anywhere, especially if the whole app basically depends on it.