-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathCounter.tsx
More file actions
29 lines (27 loc) · 832 Bytes
/
Counter.tsx
File metadata and controls
29 lines (27 loc) · 832 Bytes
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
"use client";
import { useState } from "react";
export default function Counter() {
const [count, setCount] = useState(0);
return (
<div className="flex flex-col items-center justify-center">
<h1 className="text-4xl font-bold">Counter</h1>
<p className="mt-4 text-center">
The current count is <span className="font-bold">{count}</span>.
</p>
<div className="mt-4 space-x-4">
<button
className="px-4 py-2 text-white bg-blue-500 rounded"
onClick={() => setCount((prevCount) => prevCount + 1)}
>
Increment
</button>
<button
className="px-4 py-2 text-white bg-red-500 rounded"
onClick={() => setCount((prevCount) => prevCount - 1)}
>
Decrement
</button>
</div>
</div>
);
}