@actualwave/use-element-size
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@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.current does not contain reference to HTMLElement. reinitInEffect forces immediate re-render to apply element sizes, expected to have a valid reference at the time of re-render.

Example on codesandbox.io.

Package Sidebar

Install

npm i @actualwave/use-element-size

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

3.35 kB

Total Files

4

Last publish

Collaborators

  • actualwave