-
-
Notifications
You must be signed in to change notification settings - Fork 243
Expand file tree
/
Copy pathroot.tsx
More file actions
70 lines (68 loc) · 1.83 KB
/
root.tsx
File metadata and controls
70 lines (68 loc) · 1.83 KB
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
import './index.css'
import viteLogo from '/vite.svg'
import { getServerCounter, updateServerCounter } from './action.tsx'
import reactLogo from './assets/react.svg'
import { ClientCounter } from './client.tsx'
export function Root() {
return (
<html lang="en">
<head>
<meta charSet="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + RSC</title>
</head>
<body>
<App />
</body>
</html>
)
}
function App() {
return (
<div id="root">
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a
href="https://react.dev/reference/rsc/server-components"
target="_blank"
>
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + RSC</h1>
<div className="card">
<ClientCounter />
</div>
<div className="card">
<form action={updateServerCounter.bind(null, 1)}>
<button>Server Counter: {getServerCounter()}</button>
</form>
</div>
<ul className="read-the-docs">
<li>
Edit <code>src/client.tsx</code> to test client HMR.
</li>
<li>
Edit <code>src/root.tsx</code> to test server HMR.
</li>
<li>
Visit{' '}
<a href="./_.rsc" target="_blank">
<code>/_.rsc</code>
</a>{' '}
to view RSC stream payload.
</li>
<li>
Visit{' '}
<a href="/?__nojs" target="_blank">
<code>/?__nojs</code>
</a>{' '}
to test server action without js enabled.
</li>
</ul>
</div>
)
}