diff --git a/.changeset/sweet-seals-laugh.md b/.changeset/sweet-seals-laugh.md new file mode 100644 index 00000000..dcb09267 --- /dev/null +++ b/.changeset/sweet-seals-laugh.md @@ -0,0 +1,5 @@ +--- +"react-starter-boilerplate": minor +--- + +Change /help page to be a lazy route as an example diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 28b7507e..99fb8ff8 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -8,15 +8,20 @@ // This file is auto-generated by TanStack Router +import { createFileRoute } from '@tanstack/react-router' + // Import Routes import { Route as rootRoute } from './routes/__root' import { Route as IndexImport } from './routes/index' import { Route as UsersIndexImport } from './routes/users/index' -import { Route as HelpIndexImport } from './routes/help/index' import { Route as AboutIndexImport } from './routes/about/index' import { Route as UsersIdIndexImport } from './routes/users/$id/index' +// Create Virtual Routes + +const HelpIndexLazyImport = createFileRoute('/help/')() + // Create/Update Routes const IndexRoute = IndexImport.update({ @@ -24,13 +29,13 @@ const IndexRoute = IndexImport.update({ getParentRoute: () => rootRoute, } as any) -const UsersIndexRoute = UsersIndexImport.update({ - path: '/users/', +const HelpIndexLazyRoute = HelpIndexLazyImport.update({ + path: '/help/', getParentRoute: () => rootRoute, -} as any) +} as any).lazy(() => import('./routes/help/index.lazy').then((d) => d.Route)) -const HelpIndexRoute = HelpIndexImport.update({ - path: '/help/', +const UsersIndexRoute = UsersIndexImport.update({ + path: '/users/', getParentRoute: () => rootRoute, } as any) @@ -56,14 +61,14 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof AboutIndexImport parentRoute: typeof rootRoute } - '/help/': { - preLoaderRoute: typeof HelpIndexImport - parentRoute: typeof rootRoute - } '/users/': { preLoaderRoute: typeof UsersIndexImport parentRoute: typeof rootRoute } + '/help/': { + preLoaderRoute: typeof HelpIndexLazyImport + parentRoute: typeof rootRoute + } '/users/$id/': { preLoaderRoute: typeof UsersIdIndexImport parentRoute: typeof rootRoute @@ -76,8 +81,8 @@ declare module '@tanstack/react-router' { export const routeTree = rootRoute.addChildren([ IndexRoute, AboutIndexRoute, - HelpIndexRoute, UsersIndexRoute, + HelpIndexLazyRoute, UsersIdIndexRoute, ]) diff --git a/src/routes/help/index.lazy.tsx b/src/routes/help/index.lazy.tsx new file mode 100644 index 00000000..b98527cf --- /dev/null +++ b/src/routes/help/index.lazy.tsx @@ -0,0 +1,7 @@ +import { createLazyFileRoute } from '@tanstack/react-router'; + +import { Help } from 'routes/help/-components/Help'; + +export const Route = createLazyFileRoute('/help/')({ + component: () => , +}); diff --git a/src/routes/help/index.tsx b/src/routes/help/index.tsx deleted file mode 100644 index 1b587b87..00000000 --- a/src/routes/help/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router'; - -import { Help } from 'routes/help/-components/Help'; - -export const Route = createFileRoute('/help/')({ - component: () => , -});