Files
gander/frontend/src/context/AuthContext.tsx
Chris-1010 60c19b3052 UPDATE: Fix to stream/userpage routing, Added UserPage and Tidy to code;
Added ability to visit a user's profile page from their stream;
Cleaned up code formatting, primarily changing from single quotes to double quotes;
Removed unused SignupForm component;
2025-02-04 14:59:18 +00:00

21 lines
505 B
TypeScript

import { createContext, useContext } from "react";
interface AuthContextType {
isLoggedIn: boolean;
username: string | null;
setIsLoggedIn: (value: boolean) => void;
setUsername: (value: string | null) => void;
}
export const AuthContext = createContext<AuthContextType | undefined>(
undefined,
);
export function useAuth() {
const context = useContext(AuthContext);
if (context === undefined) {
throw new Error("useAuth must be used within an AuthProvider");
}
return context;
}