The useLoaderDeps hook is a hook that returns an object with the dependencies that are used to trigger the loader for a given route.
The useLoaderDepsHook hook accepts an options object.
import { useLoaderDeps } from '@tanstack/react-router'
const routeApi = getRouteApi('/posts/$postId')
function Component() {
const deps = useLoaderDeps({ from: '/posts/$postId' })
// OR
const routeDeps = routeApi.useLoaderDeps()
// OR
const postId = useLoaderDeps({
from: '/posts',
select: (deps) => deps.view,
})
// ...
}
import { useLoaderDeps } from '@tanstack/react-router'
const routeApi = getRouteApi('/posts/$postId')
function Component() {
const deps = useLoaderDeps({ from: '/posts/$postId' })
// OR
const routeDeps = routeApi.useLoaderDeps()
// OR
const postId = useLoaderDeps({
from: '/posts',
select: (deps) => deps.view,
})
// ...
}
Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.