mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
say no to memory leaks man cook kiss
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user