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