20 lines
395 B
TypeScript
20 lines
395 B
TypeScript
|
import { NDKContext } from 'contexts/NDKContext'
|
||
|
import { useContext } from 'react'
|
||
|
|
||
|
export const useNDKContext = () => {
|
||
|
const ndkContext = useContext(NDKContext)
|
||
|
|
||
|
if (!ndkContext)
|
||
|
throw new Error(
|
||
|
'NDKContext should not be used in out component tree hierarchy'
|
||
|
)
|
||
|
|
||
|
const { ndk, fetchEvents, fetchMods } = ndkContext
|
||
|
|
||
|
return {
|
||
|
ndk,
|
||
|
fetchEvents,
|
||
|
fetchMods
|
||
|
}
|
||
|
}
|