Provides `<Rect />` and `useRect` to measure Elements via `Element.getBoundingClientRect()`.
npm install @react-lit/rectProvides and useRect to measure Elements viaElement.getBoundingClientRect().
``bash`
$ npm i @react-lit/rector
$ yarn add @react-lit/rect
`js
import * as React from 'react';
import { Rect, useRect } from "@react-lit/rect";
// (1) Example using
function RectExample() {
return (
{({ ref, rect }) => (
{JSON.stringify(rect, null, 2)}
ref={ref}
contentEditable
dangerouslySetInnerHTML={{
__html: "Edit this to change the size!",
}}
/>
)}
);
}
// (2) Example using useRect()
function UseRefExample() {
const ref = React.useRef();
const rect = useRect(ref);
return (
{JSON.stringify(rect, null, 2)}Development
(1) Install dependencies
`bash
$ npm i
or
$ yarn
`(2) Run initial validation
`bash
$ ./Taskfile.sh validate
`(3) Run tests in watch-mode to validate functionality.
`bash
$ ./Taskfile test -w
``---
_This project was set up by @jvdx/core_