UserContext
This commit is contained in:
13
src/utils/users/UseUser.ts
Normal file
13
src/utils/users/UseUser.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
import {UserContext} from "./UserContext.ts";
|
||||
import {useContext} from "react";
|
||||
|
||||
|
||||
|
||||
export function useUser() {
|
||||
const context = useContext(UserContext);
|
||||
if (!context) {
|
||||
throw new Error('useUser must be used within a UserProvider');
|
||||
}
|
||||
return context;
|
||||
}
|
||||
Reference in New Issue
Block a user