Check existence of elements before destroying (#5913)

Do not show in changelog
This commit is contained in:
Clément Pasteau
2023-11-16 15:55:58 +01:00
committed by GitHub
parent c1627b5ab2
commit e3291b515d

View File

@@ -484,6 +484,8 @@ export default class InstancesEditor extends Component<Props> {
// to protect against renders after the component is unmounted.
this._unmounted = true;
// We've seen all those elements being undefined in some cases, so
// by security, check that they are defined before deleting them.
if (this.selectionRectangle) {
this.selectionRectangle.delete();
}
@@ -501,8 +503,12 @@ export default class InstancesEditor extends Component<Props> {
}
if (this.nextFrame) cancelAnimationFrame(this.nextFrame);
stopPIXITicker();
this.pixiContainer.destroy();
this.pixiRenderer.destroy();
if (this.pixiContainer) {
this.pixiContainer.destroy();
}
if (this.pixiRenderer) {
this.pixiRenderer.destroy();
}
}
// To be updated, see https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops.