Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make /help a lazy route #174

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sweet-seals-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-starter-boilerplate": minor
---

Change /help page to be a lazy route as an example
27 changes: 16 additions & 11 deletions src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,34 @@

// 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({
path: '/',
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)

Expand All @@ -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
Expand All @@ -76,8 +81,8 @@ declare module '@tanstack/react-router' {
export const routeTree = rootRoute.addChildren([
IndexRoute,
AboutIndexRoute,
HelpIndexRoute,
UsersIndexRoute,
HelpIndexLazyRoute,
UsersIdIndexRoute,
])

Expand Down
7 changes: 7 additions & 0 deletions src/routes/help/index.lazy.tsx
tokerson marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createLazyFileRoute } from '@tanstack/react-router';

import { Help } from 'routes/help/-components/Help';

export const Route = createLazyFileRoute('/help/')({
component: () => <Help />,
});
7 changes: 0 additions & 7 deletions src/routes/help/index.tsx

This file was deleted.

Loading