Selaa lähdekoodia

don't use addCallback for triggering onCreate

ad1992 3 vuotta sitten
vanhempi
commit
c93d8f4bd0
1 muutettua tiedostoa jossa 7 lisäystä ja 10 poistoa
  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() {