import React , { ReactNode , useReducer } from 'react' ; import getUIStateContext , { initialState , SetClassModeActon , StateType } from '../context/getUIStateContext' ; const reducer = ( state , action ) : StateType => { switch ( action . type ) { case 'SET_CLASS_MODE' : return { ... state , classMode : action . payload . classMode } ; default : throw new Error ( ) ; } } ; type Props = { children : ReactNode ; } ; export default function UIStateProvider ( props ) { const { children } = props ; const UIStateContext = getUIStateContext ( ) ; return ( < UIStateContext . Provider value = { useReducer ( reducer , initialState ) } > { children } < /UIStateContext.Provider>); }