mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
chore: deprecate safeSetSize
This commit is contained in:
parent
29b647d6c5
commit
a483a4f7d3
1 changed files with 1 additions and 11 deletions
|
|
@ -19,16 +19,6 @@ export function SizeObserver({ type = 'div', children, ...rest }: Props) {
|
|||
height: undefined,
|
||||
})
|
||||
|
||||
const safeSetSize = React.useCallback(function safeSetSize(rect: DOMRectReadOnly) {
|
||||
// requestAnimationFrame fixes "ResizeObserver loop limit exceeded" error
|
||||
requestAnimationFrame(() =>
|
||||
setSize({
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
}),
|
||||
)
|
||||
}, [])
|
||||
|
||||
React.useEffect(() => {
|
||||
if (ref.current) {
|
||||
if (features.resize) {
|
||||
|
|
@ -36,7 +26,7 @@ export function SizeObserver({ type = 'div', children, ...rest }: Props) {
|
|||
const entry = entries[0]
|
||||
if (!entry) return
|
||||
const rect = entry.contentRect
|
||||
safeSetSize(rect)
|
||||
setSize(rect)
|
||||
})
|
||||
observer.observe(ref.current)
|
||||
return () => observer.disconnect()
|
||||
|
|
|
|||
Loading…
Reference in a new issue