Last active
March 13, 2022 13:36
-
-
Save pablorn91/e43b7e5f3a4b29a6de8f137303c5bfea to your computer and use it in GitHub Desktop.
Crear un Context en React
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 { createContext } from 'react' | |
const NombreContext =createContext() | |
const NombreProvider = ({children}) => { | |
//definir state, effects y funciones propias | |
return ( | |
<NombreContext.Provider | |
value={{ | |
//aqui van los props o lo que quieres que se comparta en los demas componentes | |
}} | |
> | |
{children} | |
</NombreContext.Provider> | |
) | |
} | |
export { | |
NombreProvider | |
} | |
export default NombreContext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment