mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: "ResizeObserver loop limit exceeded"
This commit is contained in:
parent
0cdb49414a
commit
5ea59c3d5f
1 changed files with 8 additions and 4 deletions
|
|
@ -27,13 +27,17 @@ export default function SizeObserver({
|
|||
const entry = entries[0]
|
||||
if (!entry) return
|
||||
const rect = entry.contentRect
|
||||
setSize({
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
})
|
||||
// requestAnimationFrame fixes "ResizeObserver loop limit exceeded" error
|
||||
requestAnimationFrame(() =>
|
||||
setSize({
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
if (ref.current) observer.observe(ref.current)
|
||||
return () => observer.disconnect()
|
||||
}, [])
|
||||
|
||||
const props: any = { ...rest, ref } // :)
|
||||
|
|
|
|||
Loading…
Reference in a new issue