Last active
July 12, 2019 03:05
-
-
Save brennancheung/8687826436cba8edbed8840f7f97eb33 to your computer and use it in GitHub Desktop.
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
export const Counter = ({ initialValue, onChange }) => { | |
const [count, setCount] = useState(initialValue) | |
useEffect(() => onChange(count), [count]) | |
const incrementCounter = () => setCount(count + 1) | |
return ( | |
<div> | |
Count: {count} | |
<button onClick={incrementCounter}>+</button> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment