Skip to content

Commit

Permalink
fix: stop "Zero-sized element, this should not happen" error from sho…
Browse files Browse the repository at this point in the history
…wing up when it should not (#1061)

* fix: stop "Zero-sized element, this should not happen" error from showing up when it should not

* chore: whitespace

---------

Co-authored-by: Petyo Ivanov <underlog@gmail.com>
  • Loading branch information
DovydasSp and petyosi committed Apr 6, 2024
1 parent 1f8c8ee commit c7a46a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hooks/useSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export function useSizeWithElRef(callback: (e: HTMLElement) => void, enabled = t
if (typeof ResizeObserver !== 'undefined') {
const observer = React.useMemo(() => {
return new ResizeObserver((entries: ResizeObserverEntry[]) => {
const element = entries[0].target as HTMLElement
if (element.offsetParent !== null) {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
const element = entries[0].target as HTMLElement
if (element.offsetParent !== null) {
callback(element)
})
}
}
})
})
}, [callback])

Expand Down

0 comments on commit c7a46a8

Please sign in to comment.