diff options
| author | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-03-25 15:32:20 +0000 |
|---|---|---|
| committer | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-03-25 15:32:20 +0000 |
| commit | 7809ccbba56be8c5377f94cf2d287a0e1521fdc1 (patch) | |
| tree | 1c590049df5546f141eeb3bf58ad5ea9d1e0fbf6 /src/context | |
| parent | d071a19fdeb0fc369e356004118f59a7fe4fed91 (diff) | |
Initial commit: App Oficina base project
Diffstat (limited to 'src/context')
| -rw-r--r-- | src/context/AppContextProvider.tsx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/context/AppContextProvider.tsx b/src/context/AppContextProvider.tsx new file mode 100644 index 0000000..75ece38 --- /dev/null +++ b/src/context/AppContextProvider.tsx @@ -0,0 +1,39 @@ +import React, { Dispatch, SetStateAction, createContext, useContext, useState } from 'react'; + +export type Usuario={ + id: string, + nick: string, + rol?: string +} + +export interface AppContextType{ + + listaUsuarios: Usuario[], + + setListaUsuarios: Dispatch<SetStateAction<Usuario[]>> +} + +export const AppContext = createContext<AppContextType>({} as AppContextType); + +const AppContextProvider = (props: any) => { + const [listaUsuarios, setListaUsuarios] = useState<Usuario[]>([]); + + + const contextValues: AppContextType = { + + listaUsuarios: listaUsuarios, + + setListaUsuarios: setListaUsuarios + } + return ( + <AppContext.Provider value={contextValues}> + {props.children} + </AppContext.Provider> + ) +} + +export const useAppContext = () =>{ + return useContext(AppContext); +} + +export default AppContextProvider
\ No newline at end of file |