From 305f4360c5110556332162128929516cc46a00fe Mon Sep 17 00:00:00 2001 From: tokerson Date: Thu, 25 Apr 2024 23:37:27 +0200 Subject: [PATCH 1/3] chore: make /help a lazy route --- src/routeTree.gen.ts | 2 +- src/routes/help/index.lazy.tsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/routes/help/index.lazy.tsx diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 28b7507e..e4ed4008 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -32,7 +32,7 @@ const UsersIndexRoute = UsersIndexImport.update({ const HelpIndexRoute = HelpIndexImport.update({ path: '/help/', getParentRoute: () => rootRoute, -} as any) +} as any).lazy(() => import('./routes/help/index.lazy').then((d) => d.Route)) const AboutIndexRoute = AboutIndexImport.update({ path: '/about/', 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: () => , +}); From 259046ffd8fddfec423b66fe14b58dba2835d2d1 Mon Sep 17 00:00:00 2001 From: tokerson Date: Thu, 25 Apr 2024 23:40:50 +0200 Subject: [PATCH 2/3] chore: add changelog --- .changeset/sweet-seals-laugh.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sweet-seals-laugh.md 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 From b0f4f8e614248d54c0fa2f160ad3a75d8927c071 Mon Sep 17 00:00:00 2001 From: tokerson Date: Mon, 6 May 2024 18:22:46 +0200 Subject: [PATCH 3/3] chore: remove old index.ts file for the help page --- src/routeTree.gen.ts | 27 ++++++++++++++++----------- src/routes/help/index.tsx | 7 ------- 2 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 src/routes/help/index.tsx diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index e4ed4008..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,16 +29,16 @@ const IndexRoute = IndexImport.update({ getParentRoute: () => rootRoute, } as any) +const HelpIndexLazyRoute = HelpIndexLazyImport.update({ + path: '/help/', + getParentRoute: () => rootRoute, +} as any).lazy(() => import('./routes/help/index.lazy').then((d) => d.Route)) + const UsersIndexRoute = UsersIndexImport.update({ path: '/users/', getParentRoute: () => rootRoute, } as any) -const HelpIndexRoute = HelpIndexImport.update({ - path: '/help/', - getParentRoute: () => rootRoute, -} as any).lazy(() => import('./routes/help/index.lazy').then((d) => d.Route)) - const AboutIndexRoute = AboutIndexImport.update({ path: '/about/', getParentRoute: () => rootRoute, @@ -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.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: () => , -});