Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dispatch using hooks
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
You can’t perform that action at this time.