import { createRoute, createRootRoute, getRouteApi } from '@tanstack/react-router';
const rootRoute = createRootRoute({});
const parentRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'parent',
loader: async () => ({ parentData: 'hello' }),
});
const childRoute = createRoute({
getParentRoute: () => parentRoute,
path: 'child',
loader: async () => ({ childData: 123 }),
});
const routeTree = rootRoute.addChildren([
parentRoute.addChildren([childRoute]),
]);
const parentApi = getRouteApi('/parent');
const data = parentApi.useLoaderData();
data.parentData;
// ❌ Error: Property 'parentData' does not exist on type '{ parentData: string; } | { childData: number; }'
import { createRoute, createRootRoute, getRouteApi } from '@tanstack/react-router';
const rootRoute = createRootRoute({});
const parentRoute = createRoute({
getParentRoute: () => rootRoute,
path: 'parent',
loader: async () => ({ parentData: 'hello' }),
});
const childRoute = createRoute({
getParentRoute: () => parentRoute,
path: 'child',
loader: async () => ({ childData: 123 }),
});
const routeTree = rootRoute.addChildren([
parentRoute.addChildren([childRoute]),
]);
const parentApi = getRouteApi('/parent');
const data = parentApi.useLoaderData();
data.parentData;
// ❌ Error: Property 'parentData' does not exist on type '{ parentData: string; } | { childData: number; }'