Created
April 15, 2018 02:10
-
-
Save nightspirit/9f80043977524df2a7b1489bb15fb08b to your computer and use it in GitHub Desktop.
react context example
This file contains 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' | |
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