16 lines
423 B
React
16 lines
423 B
React
import { createContext, useCallback, useContext, useMemo, useState } from 'react';
|
|
|
|
const AuthContext = createContext(null);
|
|
|
|
export function AuthProvider({ children }) {
|
|
|
|
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
|
}
|
|
|
|
export function useAuth() {
|
|
const ctx = useContext(AuthContext);
|
|
if (!ctx) {
|
|
throw new Error('useAuth must be used within an AuthProvider');
|
|
}
|
|
return ctx;
|
|
} |