Skip to content

Commit 8d55a22

Browse files
committed
v0.2.6; giving the README some TLC and a clear MIT license
1 parent 8fc7e8b commit 8d55a22

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# use-viewport-sizes #
22

3-
tiny React hook which allows you to track visible window viewport size in your components w/ an optional debounce for updates for optimal rendering.
3+
![npm](https://img.shields.io/npm/v/use-viewport-sizes.svg?color=blue) ![David](https://img.shields.io/david/rob2d/use-viewport-sizes.svg) ![npm](https://img.shields.io/npm/dw/use-viewport-sizes.svg?color=red) ![GitHub issues](https://img.shields.io/github/issues-raw/rob2d/use-viewport-sizes.svg) ![NPM](https://img.shields.io/npm/l/use-viewport-sizes.svg)
4+
5+
a tiny React hook which allows you to track visible window viewport size in your components w/ an optional debounce for updates for optimal rendering.
46

57
## Installation ##
68

79
```
810
npm install -D use-viewport-sizes
911
```
1012

11-
## Benefits
12-
- extremely lightweight and dependency-free -- **2.25kb with no gzip compression**
13+
## Benefits ##
14+
- extremely lightweight and dependency-free -- **2.25kb** before gzipping.
1315
- only one `window.onresize` handler used to subscribe to any changes in an unlimited number of components.
1416
- optional debounce to delay updates until user stops dragging their window for a moment; this can make expensive components with size-dependent calculations run much faster and your app feel smoother.
1517
- debouncing does not create new handlers or waste re-renders in your component; the results are also pooled from only one resize result.
@@ -24,7 +26,7 @@ npm install -D use-viewport-sizes
2426
### **Without Debouncing**
2527
*registers dimension changes on every resize event immediately*
2628

27-
```
29+
```js
2830
import React from 'react'
2931
import useViewportSizes from 'use-viewport-sizes'
3032

@@ -39,7 +41,7 @@ function MyComponent (props) {
3941
### **With Debouncing**
4042
*registers dimension changes only when a user stops dragging/resizing the window for a specified number of miliseconds; for expensive components such as data grids which may be too
4143
expensive to re-render during window resize dragging.*
42-
```
44+
```js
4345
import React from 'react'
4446
import useViewportSizes from 'use-viewport-sizes'
4547

@@ -56,7 +58,7 @@ function MyExpensivelyRenderedComponent (props) {
5658

5759
*Sidenote that you will see a `useLayoutEffect` warning from React. This is perfectly normal as there is no viewport/context to paint to when pre-rendering in SSR and will not interfere with your app once served to the client*
5860

59-
```
61+
```js
6062
import React, { useLayoutEffect } from 'react'
6163
import useViewportSizes from 'use-viewport-sizes'
6264

@@ -71,4 +73,14 @@ function MySSRComponent (props) {
7173

7274
...renderLogic
7375
}
74-
```
76+
```
77+
78+
## Support
79+
If you have read the examples and have any issues which you know are glitches,or would like to request something changed, please feel free to [post an issue on Github](https://github.com/rob2d/use-viewport-sizes/issues/new).
80+
81+
Otherwise, if this was useful and you'd like to show your support, no donations necessary, but please consider [checking out the repo](https://github.com/rob2d/use-viewport-sizes) and giving a star.
82+
83+
## License ##
84+
85+
- Open Source **[MIT license](http://opensource.org/licenses/mit-license.php)**
86+
- 2019 © <a href="http://robertconcepcion.com" target="_blank">Robert Concepción III</a>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "use-viewport-sizes",
3-
"version": "0.2.5",
4-
"description": "tiny React hook which allows you to track visible window viewport size in your components w/ an optional debounce for updates for optimal rendering.",
3+
"version": "0.2.6",
4+
"description": "tiny React hook for tracking visible window viewport size in your components w/ an optional debounce for optimal rendering.",
55
"main": "build/index.js",
66
"scripts": {
77
"start": "webpack --watch",

0 commit comments

Comments
 (0)