Skip to content

Conversation

pinpong
Copy link
Contributor

@pinpong pinpong commented Sep 23, 2025

Fix #2494 because !== null not checking if undefined
I have the same error after updating to RN0.82.0-rc4

@mgcrea
Copy link

mgcrea commented Oct 9, 2025

This is now crashing in 0.82.0:

Proper fix imo:

diff --git a/src/hooks/useBoundingClientRect.ts b/src/hooks/useBoundingClientRect.ts
index cc85c8ced2de8ec514360368ed20af733f8f9aec..cb92a016d67215a65a1d2b9ce710d6be34a36a6b 100644
--- a/src/hooks/useBoundingClientRect.ts
+++ b/src/hooks/useBoundingClientRect.ts
@@ -56,7 +56,7 @@ export function useBoundingClientRect(
     }
 
     // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
-    if (ref.current.unstable_getBoundingClientRect !== null) {
+    if (typeof ref.current.unstable_getBoundingClientRect === "function") {
       // @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
       const layout = ref.current.unstable_getBoundingClientRect();
       handler(layout);
@@ -64,7 +64,7 @@ export function useBoundingClientRect(
     }
 
     // @ts-ignore once it `unstable_getBoundingClientRect` gets stable 🤞.
-    if (ref.current.getBoundingClientRect !== null) {
+    if (typeof ref.current.getBoundingClientRect === "function") {
       // @ts-ignore once it `unstable_getBoundingClientRect` gets stable.
       const layout = ref.current.getBoundingClientRect();
       handler(layout);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash when calling unstable_getBoundingClientRect

2 participants