dify/web/app/components/base/features/context.tsx
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

17 lines
635 B
TypeScript

import type { FeaturesState, FeaturesStore } from './store'
import { createContext, useRef } from 'react'
import { createFeaturesStore } from './store'
export const FeaturesContext = createContext<FeaturesStore | null>(null)
type FeaturesProviderProps = {
children: React.ReactNode
} & Partial<FeaturesState>
export const FeaturesProvider = ({ children, ...props }: FeaturesProviderProps) => {
const storeRef = useRef<FeaturesStore | undefined>(undefined)
if (!storeRef.current) storeRef.current = createFeaturesStore(props)
return <FeaturesContext.Provider value={storeRef.current}>{children}</FeaturesContext.Provider>
}