use-bounding-rect
v0.1.0
Published
A tiny React hook to access DOM Rect dynamically
Downloads
7
Maintainers
Readme
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>
);
}