optimize boot sequnse
This commit is contained in:
17
src/contexts/auth/useAuth.ts
Normal file
17
src/contexts/auth/useAuth.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
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;
|
||||
};
|
||||
Reference in New Issue
Block a user