-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
61 lines (56 loc) · 1.03 KB
/
client.js
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
ReactDOM.hydrateRoot(document.getElementById("root"), <Home />);
const pizzas = [
{
name: "Focaccia",
price: 6,
},
{
name: "Pizza Margherita",
price: 10,
},
{
name: "Pizza Spinaci",
price: 12,
},
{
name: "Pizza Funghi",
price: 12,
},
{
name: "Pizza Prosciutto",
price: 15,
},
];
function Home() {
return (
<div style={{ backgroundColor: "gray", height: "100dvh" }}>
<h1>🍕 Fast React Pizza Co.</h1>
<p>This page has been rendered with React on the server 🤯</p>
<h2>Menu</h2>
<ul>
{pizzas.map((pizza) => (
<MenuItem pizza={pizza} key={pizza.name} />
))}
</ul>
</div>
);
}
function MenuItem({ pizza }) {
return (
<li>
<h4>
{pizza.name} (${pizza.price})
</h4>
<Counter />
</li>
);
}
function Counter() {
const [count, setCount] = React.useState(0);
return (
<div>
<button onClick={() => setCount((c) => c + 1)}>+1</button>
<span>{count}</span>
</div>
);
}