T
TanStack14mo ago
wise-white

"The useLoaderData hook accepts a single optional argument" - TypeScript says it's not optional

8 Replies
sensitive-blue
sensitive-blue14mo ago
yes, you need to pass either from to specifiy a route where you want to get the loader data from, or strict: false to get a union of everything
wise-white
wise-whiteOP14mo ago
i totally understand why an argument is required (at least for type safety), but why do the docs say "optional" and even italicize it?
sensitive-blue
sensitive-blue14mo ago
docs are wrong
rare-sapphire
rare-sapphire14mo ago
PR to fix the docs is always welcome
rare-sapphire
rare-sapphire14mo ago
useMatch hook | TanStack Router React Docs
The useMatch hook returns a RouteMatch in the component tree. The raw route match contains all of the information about a route match in the router and also powers many other hooks under the hood like useParams, useLoaderData, useRouteContext, and useSearch. useMatch options
wise-white
wise-whiteOP14mo ago
hope i'll remember to try to make a PR when i'm not on my work computer i can't (easily) contribute to anything from here
rare-sapphire
rare-sapphire14mo ago
no worries I fixed this
wise-white
wise-whiteOP14mo ago
thank you 🙏

Did you find this page helpful?