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;
21 lines
505 B
TypeScript
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;
|
|
}
|