20 lines
473 B
TypeScript
20 lines
473 B
TypeScript
import { createContext, useState } from "react";
|
|
|
|
interface loginInfo {
|
|
username: string;
|
|
isLoggedIn: boolean;
|
|
}
|
|
|
|
const AuthContext = createContext<loginInfo>({
|
|
username: "",
|
|
isLoggedIn: false,
|
|
});
|
|
|
|
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|
const [auth] = useState<loginInfo>({ username: "", isLoggedIn: false });
|
|
|
|
return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
|
|
};
|
|
|
|
export default AuthContext;
|