import React, { createContext, PropsWithChildren, useReducer } from 'react'; import { initialState, AppState, reducers } from './state'; export interface AppContextState { state: AppState; dispatch: React.Dispatch; } export const AppContext = createContext({ state: initialState, dispatch: () => undefined, }); export const AppContextProvider: React.FC = ({ children, }) => { const [store, dispatch] = useReducer(reducers, initialState); return ( {children} ); };