Getting access to parent route data in child route loader
using file-based router, how would you get access in a child route loader, to the parent route data (loader) i.e
`
`
6 Replies
absent-sapphire•6mo ago
Can you use ensureQueryData and await the result? It shouldn't be async because you have data already
variable-limeOP•6mo ago
ok, i was doing that, thought they would be an easiest way
absent-sapphire•6mo ago
Maybe there is. I'd like to know that
hilarious-sapphire•6mo ago
You might use
useChildMatches
or useLoaderData
both url are typesafevariable-limeOP•6mo ago
thats on the component, not the loader
hilarious-sapphire•6mo ago
oh my bad, I misread it 🙏
returning the data in paren't beforeLoad instead of loader would be an option? in that case you can use router context
Router Context | TanStack Router React Docs
TanStack Router's router context is a very powerful tool that can be used for dependency injection among many other things. Aptly named, the router context is passed through the router and down throug...