mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
Merge pull request #11033 from ranwawa/fix-editor-dispose-is-not-a-function
fix: 直接调用dispose函数清空编辑器插件,避免类型异常引起组件崩溃
This commit is contained in:
commit
46a2dd0ad4
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user