From 1b78e313fcf2c75a3b7832cf21063bfd7b00f276 Mon Sep 17 00:00:00 2001 From: Wildan Muhlis Date: Mon, 10 Aug 2026 19:04:42 +0700 Subject: [PATCH] fix: avoid NotFoundError when the measurement element is already detached MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The web provider removes its hidden measurement element with document.body.removeChild(element), which throws NotFoundError when the element is no longer a child of body. Anything that mutates document.body — an extension, a page-translation layer, a third-party script — can detach it before the effect cleanup runs, and the throw escapes React's passive-unmount chain as an uncaught error. Detach the listener first, then use element.remove(), which is a no-op when the node has no parent. The attached case is unchanged. --- src/NativeSafeAreaProvider.web.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NativeSafeAreaProvider.web.tsx b/src/NativeSafeAreaProvider.web.tsx index d3eceed2..7986228d 100644 --- a/src/NativeSafeAreaProvider.web.tsx +++ b/src/NativeSafeAreaProvider.web.tsx @@ -55,8 +55,8 @@ export function NativeSafeAreaProvider({ element.addEventListener(getSupportedTransitionEvent(), onEnd); onEnd(); return () => { - document.body.removeChild(element); element.removeEventListener(getSupportedTransitionEvent(), onEnd); + element.remove(); }; }, [onInsetsChange]);