An open API service indexing awesome lists of open source software.

https://github.com/jonahdc/use-multiple-rects

A React hook that retrieves the window position and dimensions of multiple elements by unique IDs.
https://github.com/jonahdc/use-multiple-rects

dimensions dom hooks measure react rect typescript

Last synced: 25 days ago
JSON representation

A React hook that retrieves the window position and dimensions of multiple elements by unique IDs.

Awesome Lists containing this project

README

          

# useMultipleRects

A React hook that retrieves the window position and dimensions of multiple elements by unique IDs.

Demo: https://use-multiple-rects.now.sh/

## Install

```
npm install --save use-multiple-rects
```

or

```
yarn add use-multiple-rects
```

## Usage

```javascript
import { useMultipleRects } from 'use-multiple-rects';

const example = () => {
const ids = ['id1', 'id2', 'id3'];

const [refs, rects] = useMultipleRects({ ids });

return (
<>

Dimensions: {JSON.stringify(rects['id1'])}

Dimensions: {JSON.stringify(rects['id2'])}

Dimensions: {JSON.stringify(rects['id3'])}

>
);
};
```

## License

MIT