import * as React from 'react'; import { useContext, createContext, FunctionComponent, useEffect, useState, } from 'react'; import { EditorViewContext } from './EditorViewContext'; import { ConfigurationChangedEvent } from '../vs/editor/common/config/editorOptions'; const initialState = { configurationChangedEvent: undefined as ConfigurationChangedEvent | undefined, }; export const ConfigurationChangedEventContext = createContext(initialState); type Props = { // nothing }; export const ConfigurationChangedEventProvider: FunctionComponent = ( props ) => { const { children } = props; const { editor } = useContext(EditorViewContext); const [configurationChangedEvent, setConfigurationChangedEvent] = useState(); useEffect(() => { editor.onDidChangeConfiguration((evt) => { setConfigurationChangedEvent(evt); }); }, [editor]); const value = { configurationChangedEvent, }; return ( {children} ); };