use-bounding-rect

0.1.0 • Public • Published

use-bounding-rect

npm install use-bounding-rect

A tiny React hook to access DOM Rect of an element dynamically.

import { useBoundingRect } from "use-bounding-rect";

function Wrapper() {
  let ref = useRef(null);
  let rect = useBoundingRect(ref);
  return (
    <div className="wrapper" ref={ref}>
      {rect != null ? <Content width={rect.width} height={rect.height} /> : null}
    </div>
  );
}

Package Sidebar

Install

npm i use-bounding-rect

Weekly Downloads

3

Version

0.1.0

License

ISC

Unpacked Size

2.46 kB

Total Files

4

Last publish

Collaborators

  • alexeyraspopov