Created
August 22, 2020 15:09
-
-
Save iamsaief/28a43c4273da36f7ca184af19f7fd2c4 to your computer and use it in GitHub Desktop.
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"; | |
function App() { | |
return ( | |
<div> | |
<Counter /> | |
</div> | |
); | |
} | |
function Counter() { | |
// Declare a new state variable, which we'll call "count" | |
const [count, setCount] = useState(0); | |
const handleIncrease = () => setCount(count + 1); | |
const handleDecrease = () => setCount(count - 1); | |
return ( | |
<div> | |
<h1> | |
Counter: | |
<button onClick={handleDecrease}>-</button> | |
<strong> {count} </strong> | |
<button onClick={handleIncrease}>+</button> | |
</h1> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment