Created
August 7, 2021 01:31
-
-
Save azeezat/26a7978836d31d28224907c0cc7db7e0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, useContext } from "react"; | |
export const initialAuthState = { | |
isLoggedIn: false, | |
}; | |
export const AuthContext = createContext({ | |
user: initialAuthState, | |
updateUserContext: () => {}, | |
clearUserContext: () => {}, | |
}); | |
export const useAuthContext = () => { | |
const context = useContext(AuthContext); | |
if (context === undefined) { | |
throw new Error("useAuthContext must be used within an AuthProvider"); | |
} | |
return context; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment