use-resize-observer
Tracks element size and position changes with ResizeObserver
Source
Docs
PackageIcon
Usage
Resize me!
| Property | Value |
|---|---|
| width | 0 |
| height | 0 |
API
The use-resize-observer hook returns a ref object that should be passed to the observed element, and the current element content rect, as returned by the ResizeObserver's callback entry.contentRect.
See the Resize Observer API documentation to learn more.
On the first render (as well as during SSR), or when no element is being observed, all of the properties are equal to 0.
See also the use-element-size hook in case you need to subscribe only to width and height.