dify/web/app/components/base/features/hooks.ts
Stephen Zhou f2842da397
chore(web): new lint setup (#30020)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
2025-12-23 16:58:55 +08:00

17 lines
484 B
TypeScript

import type { FeatureStoreState } from './store'
import { useContext } from 'react'
import { useStore } from 'zustand'
import { FeaturesContext } from './context'
export function useFeatures<T>(selector: (state: FeatureStoreState) => T): T {
const store = useContext(FeaturesContext)
if (!store)
throw new Error('Missing FeaturesContext.Provider in the tree')
return useStore(store, selector)
}
export function useFeaturesStore() {
return useContext(FeaturesContext)
}