use-element-size
Get element width and height and subscribe to changes
Usage
Loading...
API
use-element-size is a simpler version of use-resize-observer hook. Hook returns ref object that should be passed to the observed element, and the element's height and width. On the first render (as well as during SSR), or when no element is being observed, width and height properties are equal to 0.
const { ref, width, height } = useElementSize();Definition
function useElementSize<T extends HTMLElement = any>(): {
MutableRefObject<T>,
width: number,
height: number
};