mirror of
https://github.com/gromlab-ru/slm-design.git
synced 2026-08-22 15:30:16 +03:00
feat: add example
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
'use client'
|
||||
|
||||
import { useContext } from 'react'
|
||||
|
||||
import { AuthContext } from '../auth.context'
|
||||
import type { AuthContextValue } from '../types/auth-context.type'
|
||||
|
||||
/**
|
||||
* Возвращает application-scoped auth API текущего пользователя.
|
||||
*/
|
||||
export const useAuth = (): AuthContextValue => {
|
||||
const context = useContext(AuthContext)
|
||||
|
||||
if (context === null) {
|
||||
throw new Error('useAuth must be used inside AuthProvider')
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
Reference in New Issue
Block a user