Last active
April 25, 2019 13:07
-
-
Save sami616/54a3a848bb9929820f94797f4686fa7d to your computer and use it in GitHub Desktop.
Medium post component.js
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
import React from 'react' | |
import { Counter } from '../store' | |
const SomeComponent = () => { | |
const counterState = React.useContext(Counter.State) | |
const counterDispatch = React.useContext(Counter.Dispatch) | |
return ( | |
<> | |
<p>Count: {counterState.number}</p> | |
<button onClick={() => counterDispatch({type: 'increment'})}>Increment</button> | |
</> | |
) | |
} | |
export default SomeComponent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment