Skip to content

Instantly share code, notes, and snippets.

@nightspirit
Created April 15, 2018 02:10
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 nightspirit/9f80043977524df2a7b1489bb15fb08b to your computer and use it in GitHub Desktop.
Save nightspirit/9f80043977524df2a7b1489bb15fb08b to your computer and use it in GitHub Desktop.
react context example
import React from 'react'
const ctx = React.createContext()
export const {Provider, Consumer} = ctx
export const withCounter = Component => props => <Consumer>{value => <Component {...props} counter={value} />}</Consumer>
export default ctx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment