Observes an element's size via ResizeObserver.
Returns a cleanup function that disconnects the observer.
Optional
const stop = watchResize(panel, (entry) => { const { width } = entry.contentRect; if (width < 400) compact(panel); }); Copy
const stop = watchResize(panel, (entry) => { const { width } = entry.contentRect; if (width < 400) compact(panel); });
Observes an element's size via ResizeObserver.
Returns a cleanup function that disconnects the observer.