Auth
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user