T
TanStack2y ago
stormy-gold

Issues with routes registration (autocomplete)

I have this dashboard route:
const dashboardRoute = new Route({
getParentRoute: () => authenticatedRoutes,
path: "dashboard",
});

const dashboardIndexRoute = new Route({
getParentRoute: () => dashboardRoute,
path: "/",
component: Dashboard,
});

const dashboardEventIndexRoute = new Route({
getParentRoute: () => dashboardRoute,
path: "/events",
});

const dashboardEventsRoute = new Route({
getParentRoute: () => dashboardEventIndexRoute,
path: "/",
component: DashboardEventsOverview,
});

export const dashboardEventDetailsRoute = new Route({
getParentRoute: () => dashboardEventIndexRoute,
path: "$eventId",
component: DashboardEventDetails,
});
const dashboardRoute = new Route({
getParentRoute: () => authenticatedRoutes,
path: "dashboard",
});

const dashboardIndexRoute = new Route({
getParentRoute: () => dashboardRoute,
path: "/",
component: Dashboard,
});

const dashboardEventIndexRoute = new Route({
getParentRoute: () => dashboardRoute,
path: "/events",
});

const dashboardEventsRoute = new Route({
getParentRoute: () => dashboardEventIndexRoute,
path: "/",
component: DashboardEventsOverview,
});

export const dashboardEventDetailsRoute = new Route({
getParentRoute: () => dashboardEventIndexRoute,
path: "$eventId",
component: DashboardEventDetails,
});
I add those children like:
dashboardEventIndexRoute.addChildren([ dashboardEventsRoute, dashboardEventDetailsRoute ]);

dashboardRoute.addChildren([dashboardIndexRoute.addChildren([dashboardEventIndexRoute])]);

const routeTree = rootRoute.addChildren([
authenticatedRoutes.addChildren([
dashboardRoute, homeRoute, eventBaseRoute,
]),
layoutRoute.addChildren([authenticatedRoutes]),
]);
dashboardEventIndexRoute.addChildren([ dashboardEventsRoute, dashboardEventDetailsRoute ]);

dashboardRoute.addChildren([dashboardIndexRoute.addChildren([dashboardEventIndexRoute])]);

const routeTree = rootRoute.addChildren([
authenticatedRoutes.addChildren([
dashboardRoute, homeRoute, eventBaseRoute,
]),
layoutRoute.addChildren([authenticatedRoutes]),
]);
However I'm not getting the autocomplete and a typescript error if I try to navigate to /$eventId. (see screenshot below). Anyone have an idea as to what might be causing this?
No description
6 Replies
stormy-gold
stormy-goldOP2y ago
To add to this. When navigating to it manually via the url it does go to the page...
pleasant-yellow
pleasant-yellow2y ago
GitHub
Typescript error, some route paths are reported as invalid · Issue ...
Describe the bug Some context in thread https://discord.com/channels/719702312431386674/1190162020440481844 Stackblitz link even though /account/setting is valid it is reported as in valid. Type &#...
pleasant-yellow
pleasant-yellow2y ago
TLDR: nest all addChildren calls at once
stormy-gold
stormy-goldOP2y ago
I see Thank you
pleasant-yellow
pleasant-yellow2y ago
please mark this as as resolved
stormy-gold
stormy-goldOP2y ago
!resolved

Did you find this page helpful?