Created
July 25, 2022 10:54
-
-
Save yash-278/ae3730edbc57e34ba759a4d1c590cec3 to your computer and use it in GitHub Desktop.
React counter
This file contains 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 "./styles.css"; | |
import { useState } from "react"; | |
export default function App() { | |
const [count, setCount] = useState(0); | |
let incrementCount = () => { | |
setCount(count + 1); | |
}; | |
let decrementCount = () => { | |
setCount(count - 1); | |
}; | |
return ( | |
<div className="App"> | |
<div> | |
<div class="count"> | |
<h3>Count:</h3> | |
<h1>{count}</h1> | |
</div> | |
<div class="buttons"> | |
<button onClick={decrementCount}>Decrement</button> | |
<button onClick={incrementCount}>Increment</button> | |
</div> | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment