Skip to content

Instantly share code, notes, and snippets.

@Jahans3
Created December 1, 2018 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jahans3/bc095fda590449a9d83d57974afc1ee6 to your computer and use it in GitHub Desktop.
Save Jahans3/bc095fda590449a9d83d57974afc1ee6 to your computer and use it in GitHub Desktop.
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