Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/rehooks/window-size
- Owner: rehooks
- License: mit
- Created: 2018-10-25T17:33:17.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-01T01:48:44.000Z (over 3 years ago)
- Last Synced: 2024-10-07T10:09:31.586Z (2 months ago)
- Topics: browser, hooks, react, size, window
- Language: JavaScript
- Homepage:
- Size: 766 KB
- Stars: 131
- Watchers: 4
- Forks: 20
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-react-hooks - `@rehooks/window-size`
- awesome-react-hooks-cn - `@rehooks/window-size`
- awesome-react-hooks - `@rehooks/window-size`
- awesome-react-hooks - `@rehooks/window-size`
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,
// }// ...
}
```