TanStackT
TanStack16mo ago
13 replies
slow-yellow

implementing the breadcrumbs example in docs to a typescript project

In the docs there is an example to add breadcrumbs to your layout.
https://tanstack.com/router/latest/docs/framework/react/guide/router-context#processing-accumulated-route-context
export const Route = createRootRoute({
  component: () => {
    const matches = useRouterState({ select: (s) => s.matches })

    const breadcrumbs = matches
      .filter((match) => match.context.getTitle)
      .map(({ pathname, context }) => {
        return {
          title: context.getTitle(),
          path: pathname,
        }
      })

    // ...
  },
})

But how can i add this getTitle function to each
createFileRoute
function with typescript?
getting this error now
Object literal may only specify known properties, and 'getTitle' does not exist in type '(ctx: RouteContextOptions<Route<RootRoute<undefined, MyRouterContext, AnyContext, AnyContext, {}, undefined, unknown, unknown>, "", "", "/_app", "/_app", ... 7 more ..., unknown>, Record<...>, AnyContext, {}>) => any'
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.
TanStack | High Quality Open-Source Software for Web Developers
Preview image
Was this page helpful?