The useLoaderData hook returns the loader data from the closest RouteMatch in the component tree.
The useLoaderData hook accepts an options object.
import { useLoaderData } from '@tanstack/react-router'
function Component() {
const loaderData = useLoaderData({ from: '/posts/$postId' })
// ^? { postId: string, body: string, ... }
// ...
}
import { useLoaderData } from '@tanstack/react-router'
function Component() {
const loaderData = useLoaderData({ from: '/posts/$postId' })
// ^? { postId: string, body: string, ... }
// ...
}
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.