16 lines
381 B
TypeScript
16 lines
381 B
TypeScript
import { useContext } from 'react'
|
|
import { NovaKitContext } from './context'
|
|
import type { NovaKitContextValue } from '../types'
|
|
|
|
/**
|
|
* Hook 获取 NovaKit Context
|
|
*/
|
|
export function useNovaKit(): NovaKitContextValue {
|
|
const context = useContext(NovaKitContext)
|
|
if (!context) {
|
|
throw new Error('useNovaKit must be used within a NovaKitProvider')
|
|
}
|
|
return context
|
|
}
|
|
|