Last active
February 9, 2020 19:18
-
-
Save guigaoliveira/5c4e6b8276234bc9ea73ce5af147fffa 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' | |
const SimpleButton = ({ onClick, children }) => ( | |
<button onClick={onClick}>{children}</button> | |
); | |
function Counter() { | |
const [count, setCount] = useState(0); | |
const increment = () => { | |
setCount(count + 1); | |
}; | |
const decrement = () => { | |
setCount(count - 1); | |
}; | |
return ( | |
<> | |
Count: {count} <br /> | |
<SimpleButton onClick={increment}>+</SimpleButton> | |
<SimpleButton onClick={decrement}>-</SimpleButton> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment