Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Commit 428ff83

Browse files
committed
make sure nodes are destroyed when removed from keep alive
1 parent 332d01b commit 428ff83

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/primitives/KeepAlive.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const _removeKeepAlive = (
3939
): void => {
4040
const element = map.get(id);
4141
if (element) {
42+
(element.children as unknown as ElementNode).destroy();
4243
element.dispose();
4344
map.delete(id);
4445
}
@@ -50,7 +51,10 @@ export const removeKeepAliveRoute = (id: string): void =>
5051
_removeKeepAlive(keepAliveRouteElements, id);
5152

5253
const _clearKeepAlive = (map: Map<string, KeepAliveElement>): void => {
53-
map.forEach((element) => element.dispose());
54+
map.forEach((element) => {
55+
(element.children as unknown as ElementNode).destroy();
56+
element.dispose();
57+
});
5458
map.clear();
5559
};
5660

@@ -103,6 +107,7 @@ const createKeepAliveComponent = (
103107
(props.shouldDispose?.(props.id) ||
104108
(existing.children as unknown as ElementNode)?.destroyed)
105109
) {
110+
(existing.children as unknown as ElementNode).destroy();
106111
existing.dispose();
107112
map.delete(props.id);
108113
existing = undefined;
@@ -184,6 +189,7 @@ export const KeepAliveRoute = <S extends string>(
184189
(props.shouldDispose?.(key) ||
185190
(existing.children as unknown as ElementNode)?.destroyed)
186191
) {
192+
(existing.children as unknown as ElementNode).destroy();
187193
existing.dispose();
188194
keepAliveRouteElements.delete(key);
189195
existing = undefined;

0 commit comments

Comments
 (0)