Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/rehooks/window-size

React hook for subscribing to window size
https://github.com/rehooks/window-size

browser hooks react size window

Last synced: about 2 months ago
JSON representation

React hook for subscribing to window size

Awesome Lists containing this project

README

        

# `@rehooks/window-size`

> React hook for subscribing to window size

> **Note:** This is using the new [React Hooks API Proposal](https://reactjs.org/docs/hooks-intro.html)
> which is subject to change until React 16.7 final.
>
> You'll need to install `react`, `react-dom`, etc at `^16.7.0-alpha.0`

## Install

```sh
yarn add @rehooks/window-size
```

## Usage

```js
import useWindowSize from '@rehooks/window-size';

function MyComponent() {
let windowSize = useWindowSize();
// {
// innerWidth: window.innerWidth,
// innerHeight: window.innerHeight,
// outerWidth: window.outerWidth,
// outerHeight: window.outerHeight,
// }

// ...
}
```