Last active
June 30, 2021 05:09
-
-
Save eunsukimme/718733c2d6110a54400e78edb92c485f to your computer and use it in GitHub Desktop.
Simple counter component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
export default function Counter() { | |
const [count, setCount] = useState(0); | |
return ( | |
<div> | |
<h1>Counter: {count}</h1> | |
<button data-testid="dec" onClick={() => setCount((count) => count - 1)}> | |
- | |
</button> | |
<button data-testid="inc" onClick={() => setCount((count) => count + 1)}> | |
+ | |
</button> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment