Skip to content

Instantly share code, notes, and snippets.

@pablorn91
Last active March 13, 2022 13:36
Show Gist options
  • Save pablorn91/e43b7e5f3a4b29a6de8f137303c5bfea to your computer and use it in GitHub Desktop.
Save pablorn91/e43b7e5f3a4b29a6de8f137303c5bfea to your computer and use it in GitHub Desktop.
Crear un Context en React
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