Spaces:
Build error
Build error
File size: 650 Bytes
a8b3f00 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import {
createContext,
useRef,
} from 'react'
import type {
FeaturesState,
FeaturesStore,
} from './store'
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>()
if (!storeRef.current)
storeRef.current = createFeaturesStore(props)
return (
<FeaturesContext.Provider value={storeRef.current}>
{children}
</FeaturesContext.Provider>
)
}
|