Skip to content

Instantly share code, notes, and snippets.

@sami616
Last active April 25, 2019 13:07
Show Gist options
  • Save sami616/54a3a848bb9929820f94797f4686fa7d to your computer and use it in GitHub Desktop.
Save sami616/54a3a848bb9929820f94797f4686fa7d to your computer and use it in GitHub Desktop.
Medium post component.js
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