File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed File renamed without changes.
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ type AuthContextType = {
8
8
session : Session | null ;
9
9
user : User | null ;
10
10
} ;
11
- const AuthContext = createContext < AuthContextType | undefined > ( undefined ) ;
11
+ const AuthContext = createContext < AuthContextType | null > ( null ) ;
12
12
13
13
export default function AuthContextProvider ( { children } : PropsWithChildren ) {
14
14
const [ session , setSession ] = useState < Session | null > ( null ) ;
@@ -37,4 +37,10 @@ export default function AuthContextProvider({ children }: PropsWithChildren) {
37
37
) ;
38
38
}
39
39
40
- export const useAuth = ( ) => useContext ( AuthContext ) ;
40
+ export const useAuth = ( ) : AuthContextType => {
41
+ const context = useContext ( AuthContext ) ;
42
+ if ( context === null ) {
43
+ throw new Error ( 'useAuth must be used within an AuthContextProvider' ) ;
44
+ }
45
+ return context ;
46
+ } ;
You can’t perform that action at this time.
0 commit comments