Skip to content

Commit 7f9a786

Browse files
committed
v0.1.8; improve README
1 parent d03af0e commit 7f9a786

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# use-viewport-sizes #
22

3-
A tiny React hook which allows you to track visible window/document area in your components w/ an optional debounce for updates to give the most optimal experience for components with expensive renders.
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.
44

55
## Installation ##
66

@@ -12,34 +12,38 @@ npm install -D use-viewport-sizes
1212
- extremely lightweight and dependency-free; **2.8kb pre-gzipped** with all dependencies.
1313
- only one `window.onresize` handler used to subscribe to any changes in an unlimited number of components.
1414
- 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.
15-
- debouncing does not create new handlers; the results are pooled from only one result.
15+
- debouncing does not create new handlers or waste re-renders in your component; the results are also pooled from only one resize result.
1616

1717
## Usage ##
1818

19-
### See it in Action ###
20-
For an illustration of the concept, check out a CodeSandox:
19+
### **See it in Action** ###
20+
*for an illustration of the concept, check out a CodeSandox* @
2121
[https://codesandbox.io/s/j3vzpqxwww](https://codesandbox.io/s/j3vzpqxwww)
2222

23-
### Without Debouncing
24-
*(e.g. register every resize event immediately)*
23+
### **Without Debouncing**
24+
*registers dimension changes on every resize event immediately*
2525

2626
```
2727
import useViewportSizes from 'use-viewport-sizes'
2828
29-
function MyComponent () {
29+
function MyComponent (props) {
3030
const [vpWidth, vpHeight] = useViewportSizes();
31+
32+
...renderLogic
3133
}
3234
```
3335

3436

35-
### With Debouncing
36-
*for expensive components such as data grids which may be too
37+
### **With Debouncing**
38+
*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
3739
expensive to re-render during window resize dragging.*
3840
```
3941
import useViewportSizes from 'use-viewport-sizes'
4042
41-
function MyExpensiveComponent () {
43+
function MyExpensivelyRenderedComponent (props) {
4244
const [vpWidth, vpHeight] = useViewportSizes(1000); // 1s debounce
45+
46+
...renderLogic
4347
}
4448
```
4549

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-viewport-sizes",
3-
"version": "0.1.7",
3+
"version": "0.1.8",
44
"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.",
55
"main": "build/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)