import React , { useState } from "react" ; export const TestContext = React . createContext ( { } ) ; const initialState = { operationIsValid : true , } ; const TestProviders = ( { children } ) => { const [ test , setTest ] = useState ( initialState ) ; const [ monaco , monacoPoster ] = useState ( '' ) ; const testHandler = ( altKey , altValue ) => { setTest ( { ... test , [ altKey ] : altValue } ) ; console . log ( altKey , altValue , 'updatedState: ' , test ) ; } ; const resetHandler = ( ) => { setTest ( { } ) ; } ; return ( < TestContext . Provider value = { { test , testHandler , monaco , monacoPoster , resetHandler } } > { children } < /TestContext.Provider>); } ; export default TestProviders ;