This commit is contained in:
Mikan
2025-06-02 17:30:35 +03:00
parent b5b2439bd8
commit 7538faa699
18 changed files with 528 additions and 212 deletions

View File

@@ -1,13 +1,15 @@
import {UserContext} from "./UserContext.ts";
import {useContext} from "react";
import {UserContextType} from "../../types/users.ts";
export function useUser() {
export function useUser(): undefined| UserContextType {
const context = useContext(UserContext);
if (!context) {
throw new Error('useUser must be used within a UserProvider');
console.error('useUser must be used within a UserProvider');
return undefined;
}
return context;
}
}