Skip to content

Commit 727eb03

Browse files
authored
fix: add typeof guard for getBoundingClientRect in useBoundingClientRect (#2626)(by @magrinj)
1 parent 377d2de commit 727eb03

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/hooks/useBoundingClientRect.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ export function useBoundingClientRect(
6767
return;
6868
}
6969

70-
// @ts-expect-error once it `unstable_getBoundingClientRect` gets stable 🤞.
71-
if (ref.current.getBoundingClientRect !== null) {
70+
if (
71+
// @ts-expect-error once it `unstable_getBoundingClientRect` gets stable 🤞.
72+
ref.current.getBoundingClientRect !== null &&
73+
// @ts-expect-error once it `unstable_getBoundingClientRect` gets stable 🤞.
74+
typeof ref.current.getBoundingClientRect === 'function'
75+
) {
7276
// @ts-expect-error once it `unstable_getBoundingClientRect` gets stable.
7377
const layout = ref.current.getBoundingClientRect();
7478
handler(layout);

0 commit comments

Comments
 (0)