Last active
March 16, 2020 02:08
-
-
Save DennyScott/f105757d9dea921011e5c9ba7ab9b7e9 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
import React, { useState } from "react" | |
... | |
function App(props) { | |
const existingTokens = JSON.parse(localStorage.getItem("tokens")); | |
const [authTokens, setAuthTokens] = useState(existingTokens); | |
const setTokens = (data) => { | |
localStorage.setItem("tokens", JSON.stringify(data)); | |
setAuthTokens(data); | |
} | |
return ( | |
<AuthContext.Provider value={{ authTokens, setAuthTokens: setTokens }}> | |
... | |
</AuthContext.Provider> | |
); | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment