Merge pull request #11033 from ranwawa/fix-editor-dispose-is-not-a-function

fix: 直接调用dispose函数清空编辑器插件,避免类型异常引起组件崩溃
This commit is contained in:
hsm-lv 2024-10-14 10:16:59 +08:00 committed by GitHub
commit 46a2dd0ad4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -118,7 +118,7 @@ export class Editor extends React.Component<EditorProps, EditorState> {
container: any;
currentValue: any;
preventTriggerChangeEvent: boolean;
disposes: Array<{dispose: () => void}> = [];
disposes: Array<() => void> = [];
constructor(props: EditorProps) {
super(props);
@ -176,7 +176,7 @@ export class Editor extends React.Component<EditorProps, EditorState> {
const editorWillUnmount = this.props.editorWillUnmount;
editorWillUnmount && editorWillUnmount(this.editor, monaco);
}
this.disposes.forEach(({dispose}) => dispose());
this.disposes.forEach(dispose => dispose());
this.disposes = [];
this.editor?.dispose();
}
@ -187,7 +187,7 @@ export class Editor extends React.Component<EditorProps, EditorState> {
this.loadMonaco();
} else {
try {
this.disposes.forEach(({dispose}) => dispose());
this.disposes.forEach(dispose => dispose());
this.disposes = [];
if (this.editor) {
this.editor.getModel().dispose();