Files
artwork21c.sample.admin.react/src/hooks/useAuth.ts
artwork21c 767435cad4 access_token 쿠키 확인하여 로그인 상태 유지 처리
ProtectedRoute 로 로그인 필요 페이지 접근 관리
import 문을 src/ 포함된 절대경로로 개선
2026-01-02 11:21:56 +09:00

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;
};