Skip to content

Instantly share code, notes, and snippets.

@KattyaCuevas
Created April 17, 2021 20:11
Show Gist options
  • Save KattyaCuevas/eebc32642771f70645432b38a056f32a to your computer and use it in GitHub Desktop.
Save KattyaCuevas/eebc32642771f70645432b38a056f32a to your computer and use it in GitHub Desktop.
const MyContext = React.useContext({});
function MyContextProvider({ children }) {
const [state, setState] = React.useState(false);
return (
<MyContext.Provider value={{ state, setState }}>
{children}
</MyContext.Provider>
);
}
function App() {
return (
<MyContextProvider>
<MyCustomComponent />
</MyContextProvider>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment