Skip to content

Commit 31717fb

Browse files
committed
fix: component leak
1 parent 27e4fdc commit 31717fb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/react/runtime/src/snapshot.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { render } from 'preact';
1818
import type { Attributes, ContainerNode, VNode } from 'preact';
19-
import { cloneElement } from 'preact/compat';
19+
import { cloneElement, unmountComponentAtNode } from 'preact/compat';
2020
import { jsx as createVNode } from 'preact/jsx-runtime';
2121

2222
import type { Worklet, WorkletRefImpl } from '@lynx-js/react/worklet-runtime/bindings';
@@ -737,6 +737,9 @@ function renderMTC(snapshotInstance: SnapshotInstance, props: MTCProps) {
737737
if (vnode.__e) {
738738
snapshotInstance.insertBefore(vnode.__e as SnapshotInstance);
739739
(vnode.__e as SnapshotInstance).__onDestroy = () => {
740+
wrapper.insertBefore(vnode.__e);
741+
unmountComponentAtNode(wrapper);
742+
// TODO: destroy wrapper
740743
mtcComponentVNodes.delete(instanceId);
741744
};
742745
}

0 commit comments

Comments
 (0)