Skip to content

Commit

Permalink
LazyRoute完全に理解した
Browse files Browse the repository at this point in the history
  • Loading branch information
Simirall committed Jul 22, 2024
1 parent f8bb05a commit 2229b7c
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion frontend/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const LoginRouteRoute = LoginRouteImport.update({
const RouteRoute = RouteImport.update({
path: '/',
getParentRoute: () => rootRoute,
} as any)
} as any).lazy(() => import('./routes/route.lazy').then((d) => d.Route))

// Populate the FileRoutesByPath interface

Expand Down
16 changes: 13 additions & 3 deletions frontend/src/routes/login/route.lazy.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { createLazyFileRoute } from "@tanstack/react-router";

import { Login } from "./route";
import { Button } from "@mantine/core";
import { createLazyFileRoute, Link } from "@tanstack/react-router";

export const Route = createLazyFileRoute("/login")({
component: Login,
});

export function Login() {
return (
<>
<p>Login Page</p>
<Link to="/">
<Button>Top</Button>
</Link>
</>
);
}
15 changes: 1 addition & 14 deletions frontend/src/routes/login/route.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Button } from "@mantine/core";
import { Link, createFileRoute } from "@tanstack/react-router";
import { createFileRoute } from "@tanstack/react-router";

import { BACKEND_EJS_VARIABLE_KEYS } from "@/staticDataRouteOption";

export const Route = createFileRoute("/login")({
component: Login,
staticData: {
openGraph: {
title: `<%= ${BACKEND_EJS_VARIABLE_KEYS.siteName} + ' | Login' %>`,
Expand All @@ -13,14 +11,3 @@ export const Route = createFileRoute("/login")({
},
},
});

export function Login() {
return (
<>
<p>Login Page</p>
<Link to="/">
<Button>Top</Button>
</Link>
</>
);
}
21 changes: 21 additions & 0 deletions frontend/src/routes/route.lazy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Button, Group } from "@mantine/core";
import { createLazyFileRoute, Link } from "@tanstack/react-router";

import { DeleteParrot } from "./-components/DeleteParrot";

export const Route = createLazyFileRoute("/")({
component: Home,
});

function Home() {
return (
<>
<DeleteParrot />
<Group justify="center" mt="lg">
<Button component={Link} to="/login">
LOGIN
</Button>
</Group>
</>
);
}
19 changes: 1 addition & 18 deletions frontend/src/routes/route.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import { Button, Group } from "@mantine/core";
import { Link, createFileRoute } from "@tanstack/react-router";

import { DeleteParrot } from "./-components/DeleteParrot";
import { createFileRoute } from "@tanstack/react-router";

import { BACKEND_EJS_VARIABLE_KEYS } from "@/staticDataRouteOption";

export const Route = createFileRoute("/")({
component: Home,
staticData: {
openGraph: {
title: `<%= ${BACKEND_EJS_VARIABLE_KEYS.siteName} %>`,
Expand All @@ -15,16 +11,3 @@ export const Route = createFileRoute("/")({
},
},
});

function Home() {
return (
<>
<DeleteParrot />
<Group justify="center" mt="lg">
<Button component={Link} to="/login">
LOGIN
</Button>
</Group>
</>
);
}

0 comments on commit 2229b7c

Please sign in to comment.