Skip to content

Instantly share code, notes, and snippets.

@Wellers0n
Created September 30, 2020 19:10
Show Gist options
  • Save Wellers0n/24d0bb7c0fa44398a41ca88a96dc2238 to your computer and use it in GitHub Desktop.
Save Wellers0n/24d0bb7c0fa44398a41ca88a96dc2238 to your computer and use it in GitHub Desktop.
context
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