Last active
December 10, 2018 18:24
-
-
Save Jahans3/4984b39287ebdb97fa247f8ecf331dcb to your computer and use it in GitHub Desktop.
Dispatching actions
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 () { | |
return ( | |
<StateConsumer> | |
{({ state, dispatch }) => ( | |
<> | |
<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> | |
</> | |
)} | |
</StateConsumer> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment