浏览代码

don't use addCallback for triggering onCreate

ad1992 3 年之前
父节点
当前提交
c93d8f4bd0
共有 1 个文件被更改,包括 7 次插入10 次删除
  1. 7 10
      src/components/App.tsx

+ 7 - 10
src/components/App.tsx

@@ -458,20 +458,17 @@ class App extends React.Component<AppProps, AppState> {
       locked: false,
     });
 
-    const unbind = this.scene.addCallback(() => {
-      const customElementConfig = getCustomElementConfig(
-        this.props.customElementsConfig,
-        customElement.customType,
-      );
-      if (customElementConfig && customElementConfig.onCreate) {
-        customElementConfig.onCreate(customElement);
-      }
-    });
     this.scene.replaceAllElements([
       ...this.scene.getElementsIncludingDeleted(),
       customElement,
     ]);
-    unbind();
+    const customElementConfig = getCustomElementConfig(
+      this.props.customElementsConfig,
+      customElement.customType,
+    );
+    if (customElementConfig && customElementConfig.onCreate) {
+      customElementConfig.onCreate(customElement);
+    }
   };
 
   private renderCanvas() {