T
TanStack16mo ago
jolly-crimson

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,
});
import { createLazyFileRoute } from '@tanstack/react-router';

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

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

export const Route = createLazyFileRoute('/$lang/_layout/my-route/')({
component: MyRoute,
});
1 Reply
quickest-silver
quickest-silver16mo ago
can you please provide a minimal complete example by forking an existing example on stackblitz? https://tanstack.com/router/v1/docs/framework/react/examples/quickstart-file-based
React TanStack Router Quickstart File Based Example | TanStack Rout...
An example showing how to implement Quickstart File Based in React using TanStack Router.

Did you find this page helpful?