# react-hooks-get-dimensions

> Get a react component&#x27;s or window dimensions

Latest version **1.1.0** (published 2020-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-hooks-get-dimensions
pnpm add react-hooks-get-dimensions
yarn add react-hooks-get-dimensions
bun add react-hooks-get-dimensions
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-05-02 |
| First published | 2020-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 584.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | ilhantekir |
| Maintainers | ilhan.tekir |

## Links

- npm: https://www.npmjs.com/package/react-hooks-get-dimensions
- Repository: https://github.com/ilhantekir/React-Hooks-Get-Dimensions
- Homepage: https://github.com/ilhantekir/React-Hooks-Get-Dimensions#readme
- Issues: https://github.com/ilhantekir/React-Hooks-Get-Dimensions/issues
- npm.io page: https://npm.io/package/react-hooks-get-dimensions

## Recent versions

- 1.1.0 (latest) — 2020-05-02
- 1.0.4 — 2020-05-02
- 1.0.3 — 2020-05-02
- 1.0.2 — 2020-05-02
- 1.0.1 — 2020-05-02
- 1.0.0 — 2020-05-02

## README

# React hooks get dimensions

React-hooks-get-dimensions is a helpful to get a react component's or window dimensions.
Uses a [`Window: resize event`](https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event) to detect when an element's dimensions have changed.


## Install

`yarn add react-hooks-get-dimensions`

`npm install react-hooks-get-dimensions --save`

## Measure Component

### Example

```javascript
import  React, { useRef } from  'react';
import { useGetDimensions } from 'react-hooks-get-dimensions'
const  App = () => {
const  componentRef = useRef()
const { width, height } = useGetDimensions(componentRef);
return (
     <div ref={componentRef}>
         <p>width: {width}px</p>
         <p>height: {height}px</p>
     </div>
)}
export  default  App;
```


## Measure Viewport

### Example

```javascript
import { useGetDimensions } from 'react-hooks-get-dimensions'
const  App = () => {
const { width, height } = useGetDimensions();
return (
     <div>
          <p>width: {width}px</p>
          <p>height: {height}px</p>
     </div>
)}
export  default  App;
```


## License

MIT © [ilhantekir](https://github.com/ilhantekir)

---
_Source: https://npm.io/package/react-hooks-get-dimensions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
