koval-ui
Version:
React components collection with minimalistic design. Supports theming, layout, and input validation.
1 lines • 1.4 kB
Source Map (JSON)
{"version":3,"file":"createStoreProvider.cjs","sources":["../../../../src/internal/store/createStoreProvider.tsx"],"sourcesContent":["import type {ReactNode, Context} from 'react';\nimport {useReducer, useMemo} from 'react';\n\ntype FactoryProps<TState, TAction> = {\n context: Context<{dispatch: (action: TAction) => void; state: TState}>;\n reducer: (state: TState, action: TAction) => TState;\n initialState: TState;\n};\n\nexport const createStoreProvider =\n <TState, TAction>({initialState, reducer, context}: FactoryProps<TState, TAction>) =>\n // eslint-disable-next-line react/display-name\n ({children}: {children?: ReactNode}) => {\n const {Provider} = context;\n const [state, dispatch] = useReducer(reducer, initialState);\n const memoizedValue = useMemo(() => ({state, dispatch}), [state]);\n return <Provider value={memoizedValue}>{children}</Provider>;\n };\n"],"names":["createStoreProvider","initialState","reducer","context","children","Provider","state","dispatch","useReducer","memoizedValue","useMemo","jsx"],"mappings":"qJASaA,EACT,CAAkB,CAAC,aAAAC,EAAc,QAAAC,EAAS,QAAAC,CAAO,IAEjD,CAAC,CAAC,SAAAC,CAAA,IAAsC,CAC9B,KAAA,CAAC,SAAAC,GAAYF,EACb,CAACG,EAAOC,CAAQ,EAAIC,EAAAA,WAAWN,EAASD,CAAY,EACpDQ,EAAgBC,UAAQ,KAAO,CAAC,MAAAJ,EAAO,SAAAC,IAAY,CAACD,CAAK,CAAC,EAChE,OAAQK,EAAAA,IAAAN,EAAA,CAAS,MAAOI,EAAgB,SAAAL,CAAS,CAAA,CAAA"}