-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Estado Global Franco, esto medio que ya quedó, pero estoy teniendo unos problemas. La página no se está renderizando correctamente. * Nombre de variable cambiado {contenido} por {children}
- Loading branch information
Showing
6 changed files
with
31 additions
and
26 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { createContext } from "react"; | ||
import { createContext, useContext } from "react"; | ||
|
||
export const PruebaContext = createContext(null); | ||
export const TContext = createContext(); | ||
|
||
export const useEstadoGlobal = () => useContext(TContext); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEffect, useState } from "react"; | ||
import { TContext } from "./Context"; | ||
|
||
const tokenSesion = () => { | ||
const obtenerToken = localStorage.getItem("token"); | ||
const tokenn = JSON.parse(obtenerToken); | ||
return tokenn; | ||
}; | ||
|
||
export const EstadoGlobal = ({ children }) => { | ||
const [token, setToken] = useState(null); | ||
console.log("token actual", token) | ||
|
||
useEffect(() => { | ||
setToken(tokenSesion()); | ||
},[]); | ||
|
||
return ( | ||
<TContext.Provider value={{ token, setToken }}> | ||
{children} | ||
</TContext.Provider> | ||
); | ||
}; |
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