Newer
Older
// @ts-strict-ignore
Joel Jeremy Marquez
committed
export function useResizeObserver(
Michael Clark
committed
func: (contentRect: DOMRectReadOnly) => void,
if (!observer.current) {
observer.current = new ResizeObserver(entries => {
func(entries[0].contentRect);
});
}
observer.current.disconnect();
if (el) {
observer.current.observe(el, { box: 'border-box' });
}
}, []);
return elementRef;
}