About page for tests

This commit is contained in:
Julien Valverdé
2024-07-18 02:21:46 +02:00
parent 99d192bc43
commit 0b695506cf
3 changed files with 46 additions and 3 deletions

View File

@@ -16,10 +16,16 @@ import { Route as rootRoute } from './routes/__root'
// Create Virtual Routes // Create Virtual Routes
const AboutLazyImport = createFileRoute('/about')()
const IndexLazyImport = createFileRoute('/')() const IndexLazyImport = createFileRoute('/')()
// Create/Update Routes // Create/Update Routes
const AboutLazyRoute = AboutLazyImport.update({
path: '/about',
getParentRoute: () => rootRoute,
} as any).lazy(() => import('./routes/about.lazy').then((d) => d.Route))
const IndexLazyRoute = IndexLazyImport.update({ const IndexLazyRoute = IndexLazyImport.update({
path: '/', path: '/',
getParentRoute: () => rootRoute, getParentRoute: () => rootRoute,
@@ -36,12 +42,22 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof IndexLazyImport preLoaderRoute: typeof IndexLazyImport
parentRoute: typeof rootRoute parentRoute: typeof rootRoute
} }
'/about': {
id: '/about'
path: '/about'
fullPath: '/about'
preLoaderRoute: typeof AboutLazyImport
parentRoute: typeof rootRoute
}
} }
} }
// Create and export the route tree // Create and export the route tree
export const routeTree = rootRoute.addChildren({ IndexLazyRoute }) export const routeTree = rootRoute.addChildren({
IndexLazyRoute,
AboutLazyRoute,
})
/* prettier-ignore-end */ /* prettier-ignore-end */
@@ -51,11 +67,15 @@ export const routeTree = rootRoute.addChildren({ IndexLazyRoute })
"__root__": { "__root__": {
"filePath": "__root.tsx", "filePath": "__root.tsx",
"children": [ "children": [
"/" "/",
"/about"
] ]
}, },
"/": { "/": {
"filePath": "index.lazy.tsx" "filePath": "index.lazy.tsx"
},
"/about": {
"filePath": "about.lazy.tsx"
} }
} }
} }

View File

@@ -1,4 +1,4 @@
import { Outlet, createRootRoute } from "@tanstack/react-router" import { Link, Outlet, createRootRoute } from "@tanstack/react-router"
import { Suspense, lazy } from "react" import { Suspense, lazy } from "react"
@@ -12,6 +12,16 @@ const TanStackRouterDevtools = process.env.NODE_ENV === "production"
export function Root() { export function Root() {
return <> return <>
<div className="container mx-auto mt-8"> <div className="container mx-auto mt-8">
<div className="flex flex-row gap-2 justify-center content-center">
<Link to="/">
Home
</Link>
<Link to="/about">
About
</Link>
</div>
<Outlet /> <Outlet />
</div> </div>

View File

@@ -0,0 +1,13 @@
import { createLazyFileRoute } from "@tanstack/react-router"
import { observer } from "mobx-react-lite"
export const About = observer(() => {
return <>
<p className="mx-auto">About</p>
</>
})
export const Route = createLazyFileRoute("/about")({ component: About })