@actualwave/use-element-size
v0.0.1
Published
React hook that watches for updates and returns element size.
Downloads
2
Maintainers
Readme
@actualwave/use-element-size
React hook that watches for changes in element size using ResizeObserver and reports updates forcing component to render. There are two hooks in this package
- useResizeObserver(handlerFn, elementRef) -- Calls
handlerFn()when element size changed with instance of DOMRectReadOnly. - useElementSize(elementRef, reinitInEffect = true) -- Returns element size or null if
elementRef.currentdoes not contain reference to HTMLElement.reinitInEffectforces immediate re-render to apply element sizes, expected to have a valid reference at the time of re-render.
Example on codesandbox.io.
