From 9bd582e4e69fa7c368a0180cc7cf4ca37e320057 Mon Sep 17 00:00:00 2001 From: Nikhil Kumar Choudhary <112749017+fab-nikhil@users.noreply.github.com> Date: Wed, 15 Oct 2025 17:04:54 +0000 Subject: [PATCH 1/2] fix: add check for undefined as well for unstable_getBoundingClientRect and getBoundingClientRect --- src/hooks/useBoundingClientRect.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useBoundingClientRect.ts b/src/hooks/useBoundingClientRect.ts index cc85c8ced..32b8188d4 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 (ref.current.unstable_getBoundingClientRect !== null && ref.current.unstable_getBoundingClientRect !== undefined) { // @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 (ref.current.getBoundingClientRect !== null && ref.current.getBoundingClientRect !== undefined) { // @ts-ignore once it `unstable_getBoundingClientRect` gets stable. const layout = ref.current.getBoundingClientRect(); handler(layout); From 72f05dea4cf8318e7e7576e209fc33e6234e615b Mon Sep 17 00:00:00 2001 From: Nikhil Kumar Choudhary <112749017+fab-nikhil@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:20:20 +0530 Subject: [PATCH 2/2] Refactor getBoundingClientRect checks for functions --- src/hooks/useBoundingClientRect.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useBoundingClientRect.ts b/src/hooks/useBoundingClientRect.ts index 32b8188d4..67294e427 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 && ref.current.unstable_getBoundingClientRect !== undefined) { + 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 && ref.current.getBoundingClientRect !== undefined) { + if (typeof ref.current.getBoundingClientRect === 'function') { // @ts-ignore once it `unstable_getBoundingClientRect` gets stable. const layout = ref.current.getBoundingClientRect(); handler(layout);