TanStackT
TanStack2y ago
1 reply
moderate-tomato

Issue with Route.useParams() in a lazy file route

Hi Everyone!

we started our project using TanstackRouter v1.19 and declared a lazy file route (as below) and we could access the route params via Route.useParams() and all was working fine.

Now in TanstackRouter v.1.34 the same code has errors and lang param is unknown

can you help me figure it out what is wrong and how to fix that?

we can't update to a newer version with all those errors.

Below example is of course simple representation how we were accessing path params but any param in the route is now unknown.

Appreciate all the help.

import { createLazyFileRoute } from '@tanstack/react-router';

const MyRoute = () => {
  const { lang } = Route.useParams();

  return <>{lang}</>;
};

export const Route = createLazyFileRoute('/$lang/_layout/my-route/')({
  component: MyRoute,
});
Was this page helpful?