-
-
Notifications
You must be signed in to change notification settings - Fork 496
/
__root.tsx
96 lines (93 loc) · 2.58 KB
/
__root.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import * as React from 'react'
import {
Link,
Outlet,
createRootRouteWithContext,
useRouterState,
} from '@tanstack/react-router'
import { DehydrateRouter } from '@tanstack/react-router-server/client'
import { RouterContext } from '../routerContext'
export const Route = createRootRouteWithContext<RouterContext>()({
component: RootComponent,
})
function RootComponent() {
const location = useRouterState({ select: (s) => s.location })
console.log('[location]', location)
return (
<html lang="en">
<head>
<meta charSet="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script src="https://cdn.tailwindcss.com" />
<script
type="module"
suppressHydrationWarning
dangerouslySetInnerHTML={{
__html: `
import RefreshRuntime from "/@react-refresh"
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
window.__vite_plugin_react_preamble_installed__ = true
`,
}}
/>
<script type="module" src="/@vite/client" />
<script type="module" src="/src/entry-client.tsx" />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
<Link
to="/repro/$id"
params={{ id: '✅' }}
activeProps={{
className: 'font-bold',
}}
>
Repro1
</Link>
<Link
to="/repro/$id"
params={{ id: encodeURI('✅') }}
activeProps={{
className: 'font-bold',
}}
>
Repro2
</Link>
<Link
to="/"
activeProps={{
className: 'font-bold',
}}
activeOptions={{ exact: true }}
>
Home
</Link>{' '}
<Link
to="/posts"
activeProps={{
className: 'font-bold',
}}
>
Posts
</Link>{' '}
<Link
to="/error"
activeProps={{
className: 'font-bold',
}}
>
Error
</Link>
</div>
<hr />
<Outlet /> {/* Start rendering router matches */}
<TanStackRouterDevtools position="bottom-right" />
<DehydrateRouter />
</body>
</html>
)
}