15 lines
413 B
TypeScript
15 lines
413 B
TypeScript
"use client";
|
|
|
|
import React, { useContext } from 'react';
|
|
import { AuthContext } from '../lib/auth';
|
|
|
|
// Создаем собственную реализацию хука useAuth
|
|
export function useAuth() {
|
|
const context = useContext(AuthContext);
|
|
|
|
if (context === undefined) {
|
|
throw new Error("useAuth должен использоваться внутри AuthProvider");
|
|
}
|
|
|
|
return context;
|
|
}
|