Files
profi-frontend/src/utils/users/UseUser.ts

16 lines
382 B
TypeScript
Raw Normal View History

2025-06-01 21:39:44 +03:00
import {UserContext} from "./UserContext.ts";
import {useContext} from "react";
2025-06-02 17:30:35 +03:00
import {UserContextType} from "../../types/users.ts";
2025-06-01 21:39:44 +03:00
2025-06-02 17:30:35 +03:00
export function useUser(): undefined| UserContextType {
2025-06-01 21:39:44 +03:00
const context = useContext(UserContext);
if (!context) {
2025-06-02 17:30:35 +03:00
console.error('useUser must be used within a UserProvider');
return undefined;
2025-06-01 21:39:44 +03:00
}
return context;
2025-06-02 17:30:35 +03:00
}