Created
December 1, 2018 01:41
-
-
Save Jahans3/bc095fda590449a9d83d57974afc1ee6 to your computer and use it in GitHub Desktop.
Dispatch using hooks
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
export default function SomeCount () { | |
const [state, dispatch] = useStore(); | |
return ( | |
<> | |
<p> | |
Count: {state.count} | |
</p> | |
<button onClick={() => dispatch(addOne())}> | |
+ 1 | |
</button> | |
<button onClick={() => dispatch(addN(5))}> | |
+ 5 | |
</button> | |
<button onClick={() => dispatch(addN(10))}> | |
+ 10 | |
</button> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment