13 lines
275 B
TypeScript
13 lines
275 B
TypeScript
|
|
|
||
|
|
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;
|
||
|
|
}
|