Last active
May 17, 2019 17:57
-
-
Save dewey92/cf311abd4adef7320528504faf271cf9 to your computer and use it in GitHub Desktop.
Hack 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
// ... | |
const Counter = () => { | |
// ... | |
const decr = () => { | |
if (state === 0) { | |
alert('Ya akhi, nilai counter ndak boleh di bawah 0 😚'); | |
} else { | |
dispatch('DECREMENT'); | |
} | |
} | |
return ( | |
<div> | |
<button onClick={() => dispatch('INCREMENT')}>+</button> | |
{counter} | |
<button onClick={decr}>-</button> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment