Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
React.useEffect(() => {
const model = (modelRef.current = monaco.editor.createModel(code, language, filename ? monaco.Uri.parse(filename) : undefined));
const editor = monaco.editor.create(divRef.current!, {
minimap: { enabled: false },
fontFamily: CODE_FONT_FAMILY,
ariaLabel,
accessibilityHelpUrl: 'https://github.com/Microsoft/monaco-editor/wiki/Monaco-Editor-Accessibility-Guide',
// add editorOptions default value here (NOT in main destructuring) to avoid re-calling the effect
...(editorOptions || {}),
model
});
// Handle changes (debounced)
// tslint:disable-next-line:no-any due to mismatch between Node and browser typings
let debounceTimeout: any;
editor.onDidChangeModelContent(() => {
// Destructure these locally to get the latest values
const { debounceTime: currDebounceTime, onChange: currOnChange } = internalState.current!;