Protect against creating React editor without parent node

This commit is contained in:
Laurent Nguyen 2024-05-16 09:48:01 +02:00
parent 04989c6e1b
commit 3b8fabb227

View File

@ -132,7 +132,13 @@ export class EditorReact extends React.Component<EditorReactProps, EditorReactSt
this.rootNode.innerHTML = "";
const monaco = await loadMonaco();
createCallback(monaco?.editor?.create(this.rootNode, options));
try {
createCallback(monaco?.editor?.create(this.rootNode, options));
} catch (error) {
// This could happen if the parent node suddenly disappears during create()
console.error("Unable to create EditorReact", error);
return;
}
if (this.rootNode.innerHTML) {
this.setState({