Skip to content

Commit 3a99ee4

Browse files
authored
fix: fixed function undefined error in useBoundingClientRect (#2561)(by @tylerdgenius, @fab-nikhil, @pinpong)
1 parent d12f3f7 commit 3a99ee4

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/hooks/useBoundingClientRect.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,20 @@ export function useBoundingClientRect(
5555
return;
5656
}
5757

58-
// @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
59-
if (ref.current.unstable_getBoundingClientRect !== null) {
60-
// @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
58+
// @ts-expect-error 👉 https://github.com/facebook/react/commit/53b1f69ba
59+
if (
60+
ref.current.unstable_getBoundingClientRect !== null &&
61+
typeof ref.current.unstable_getBoundingClientRect === 'function'
62+
) {
63+
// @ts-expect-error https://github.com/facebook/react/commit/53b1f69ba
6164
const layout = ref.current.unstable_getBoundingClientRect();
6265
handler(layout);
6366
return;
6467
}
6568

66-
// @ts-ignore once it `unstable_getBoundingClientRect` gets stable 🤞.
69+
// @ts-expect-error once it `unstable_getBoundingClientRect` gets stable 🤞.
6770
if (ref.current.getBoundingClientRect !== null) {
68-
// @ts-ignore once it `unstable_getBoundingClientRect` gets stable.
71+
// @ts-expect-error once it `unstable_getBoundingClientRect` gets stable.
6972
const layout = ref.current.getBoundingClientRect();
7073
handler(layout);
7174
}

0 commit comments

Comments
 (0)