12 lines
324 B
TypeScript
12 lines
324 B
TypeScript
import { useContext } from 'react';
|
|
import { AuthContext, AuthContextType } from 'src/context/AuthContext';
|
|
|
|
export const useAuth = (): AuthContextType => {
|
|
const context = useContext(AuthContext);
|
|
|
|
if (!context) {
|
|
throw new Error('useAuth must be used within an AuthProvider');
|
|
}
|
|
|
|
return context;
|
|
}; |