UNPKG

@uiw/react-native

Version:
24 lines 532 B
import React, { createContext, useReducer } from 'react'; export const initialState = {}; const Context = createContext({ state: initialState, dispatch: () => null }); const reducer = (state, action) => { return { ...state, ...action }; }; const Provider = ({ contextProps, children }) => { const [state, dispatch] = useReducer(reducer, initialState); return <Context.Provider value={{ ...contextProps, state, dispatch }}>{children}</Context.Provider>; }; export { Context, reducer, Provider };