Created
April 17, 2021 20:11
-
-
Save KattyaCuevas/eebc32642771f70645432b38a056f32a to your computer and use it in GitHub Desktop.
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
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