Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
raw
history blame
445 Bytes
import { ChartContext } from './contexts'
import { useContext, useMemo } from 'react'
export function useChart<T>(generator?: () => T) {
const context = useContext(ChartContext)
if (context === undefined) {
throw new Error('useChart must be used within a ChartContextProvider')
}
const [key, flavor] = context
const [data] = useMemo(() => [generator?.(), key], [generator, key])
return [data, flavor] as [T, typeof flavor]
}