Created
September 30, 2020 19:10
-
-
Save Wellers0n/24d0bb7c0fa44398a41ca88a96dc2238 to your computer and use it in GitHub Desktop.
context
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' | |
const Context = React.createContext({}) | |
const withContext = Component => props => { | |
const [state, setState] = React.useState() | |
return ( | |
<Context.Provider value={[state, setState]}> | |
<Component {...props} /> | |
</Context.Provider> | |
) | |
} | |
export { withContext, Context } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment