Skip to content

Commit aca2be7

Browse files
author
兵人
committed
fix: 修复chart未清除缓存的组件的问题
1 parent 9aa91bf commit aca2be7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/f2/src/chart/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ class Chart<
177177
if (!layout) return;
178178
const { componentsPosition } = this;
179179
const componentPosition = { component, layout };
180+
// 清除已经卸载的component
181+
this.removeComponentsPositionCache();
182+
180183
const existIndex = findIndex(componentsPosition, (item) => {
181184
return item.component === component;
182185
});
@@ -199,6 +202,17 @@ class Chart<
199202
this.updateCoordLayout(layout);
200203
}
201204

205+
removeComponentsPositionCache() {
206+
if (!this.componentsPosition?.length) return;
207+
208+
for(let i = this.componentsPosition.length; i>-1; i--) {
209+
const item = this.componentsPosition[i];
210+
if (item && item.component && item.component.destroyed) {
211+
this.componentsPosition.splice(i, 1)
212+
}
213+
}
214+
}
215+
202216
getGeometrys() {
203217
// @ts-ignore
204218
const { children } = this.children;

0 commit comments

Comments
 (0)