Dispatching actions
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