Teact: Fix unexpected ref reset

This commit is contained in:
Alexander Zinchuk 2022-09-16 18:28:42 +02:00
parent 5652dd1fc4
commit 819280b191

View File

@ -299,10 +299,10 @@ export function unmountRealTree($element: VirtualElement) {
if (isTagElement($element)) {
if ($element.target) {
removeAllDelegatedListeners($element.target as HTMLElement);
}
if ($element.props.ref) {
$element.props.ref.current = undefined; // Help GC
if ($element.props.ref?.current === $element.target) {
$element.props.ref.current = undefined;
}
}
}