Download web/app/components/base/features/hooks.ts from ZHZ1024/dify: direct link, hf CLI and curl.
- Browser
- Download file 484 Bytes
-
https://huggingface.co/spaces/ZHZ1024/dify/resolve/main/web/app/components/base/features/hooks.ts
- Command line
-
hf download hf://spaces/ZHZ1024/dify/web/app/components/base/features/hooks.ts
-
curl -L -o hooks.ts https://huggingface.co/spaces/ZHZ1024/dify/resolve/main/web/app/components/base/features/hooks.ts
484 Bytes
| import { useContext } from 'react' | |
| import { useStore } from 'zustand' | |
| import { FeaturesContext } from './context' | |
| import type { FeatureStoreState } from './store' | |
| 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) | |
| } | |