T
TanStack13mo ago
harsh-harlequin

routeTree.gen.ts setting the wrong parent

hey guys. I have a file route defined as
# in: src/routes/~tree/~$treeId/~test/~$testId/~index.tsx

export const Route = createFileRoute('/tree/$treeId/test/$testId/')({
component: () => <TestDetails />,
});
# in: src/routes/~tree/~$treeId/~test/~$testId/~index.tsx

export const Route = createFileRoute('/tree/$treeId/test/$testId/')({
component: () => <TestDetails />,
});
and i was expecting /tree/$treeId as a parent but in the routeTree.gen.ts i only have the rootRoute as parent
const TreeTreeIdTestTestIdIndexRoute = TreeTreeIdTestTestIdIndexImport.update({
path: '/tree/$treeId/test/$testId/',
getParentRoute: () => rootRoute,
} as any)
const TreeTreeIdTestTestIdIndexRoute = TreeTreeIdTestTestIdIndexImport.update({
path: '/tree/$treeId/test/$testId/',
getParentRoute: () => rootRoute,
} as any)
my goal is to inherit the search params from /tree/$treeId
5 Replies
metropolitan-bronze
metropolitan-bronze13mo ago
please provide a complete minimal example e.g. by forking one of the existing router examples on stackblitz
harsh-harlequin
harsh-harlequinOP13mo ago
Sure! Minimal example -> https://stackblitz.com/edit/tanstack-router-a5btfw?file=src%2Froutes%2Fposts%2Fmypost%2Findex.tsx,src%2FrouteTree.gen.ts,src%2Froutes%2F__root.tsx&preset=node Here my goal its to make the routeTree.gen.ts recognize /posts/ as parent of /mypost/
metropolitan-bronze
metropolitan-bronze13mo ago
then you need to create a route for /posts/ it's missing either add /routes/posts.tx or /routes/posts/route.tx
harsh-harlequin
harsh-harlequinOP13mo ago
thanks @Manuel Schiller , I thought that /posts/index would be my route here
metropolitan-bronze
metropolitan-bronze13mo ago
no, that is the leaf route that will be rendered if you access /posts.

Did you find this page helpful?