Files
zellyy-finance/src/contexts/auth/useAuth.ts
2025-03-19 07:27:10 +09:00

18 lines
531 B
TypeScript

import { useContext, createContext } from 'react';
import { AuthContextType } from './types';
// AuthContext 생성
export const AuthContext = createContext<AuthContextType | undefined>(undefined);
/**
* 인증 컨텍스트에 접근하기 위한 커스텀 훅
* AuthProvider 내부에서만 사용해야 함
*/
export const useAuth = () => {
const context = useContext(AuthContext);
if (context === undefined) {
throw new Error('useAuth는 AuthProvider 내부에서 사용해야 합니다');
}
return context;
};