say no to memory leaks man cook kiss

This commit is contained in:
Brandy Carney
2024-07-15 18:09:24 -04:00
parent a331afe253
commit 82bda3e20d

View File

@@ -1,6 +1,6 @@
import type { ComponentInterface } from '@stencil/core';
import { Component, Element, Host, Listen, h } from '@stencil/core';
import { addEventListener } from '@utils/helpers';
import { addEventListener, removeEventListener } from '@utils/helpers';
@Component({
tag: 'ion-segment-view',
@@ -35,6 +35,14 @@ export class SegmentView implements ComponentInterface {
}
}
disconnectedCallback() {
const segmentEl = this.segmentEl;
if (segmentEl) {
removeEventListener(segmentEl, 'ionChange', this.updateSection);
this.segmentEl = null;
}
}
private updateSection = () => {
const { segmentEl } = this;