react-fetch-hook
Advanced tools
Comparing version 1.6.2 to 1.6.3
{ | ||
"name": "react-fetch-hook", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "React fetch hook", | ||
@@ -13,2 +13,3 @@ "scripts": { | ||
"run:example:depends": "parcel ./examples/depends/index.html", | ||
"run:example:pagination": "parcel ./examples/pagination/index.html --no-cache", | ||
"prepublish": "npm run flow:check && npm run typescript && npm run lint && npm run size && npm run test" | ||
@@ -40,3 +41,3 @@ }, | ||
], | ||
"limit": "186 B", | ||
"limit": "227 B", | ||
"path": "usePaginatedRequest.js" | ||
@@ -60,4 +61,3 @@ } | ||
"flow:check", | ||
"test", | ||
"size" | ||
"test" | ||
], | ||
@@ -85,2 +85,3 @@ "repository": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-transform-runtime": "^7.4.4", | ||
"@babel/preset-env": "^7.2.0", | ||
@@ -114,2 +115,3 @@ "@babel/preset-flow": "^7.0.0", | ||
"react-dom": "^16.8.0", | ||
"react-infinite-scroller": "^1.2.4", | ||
"react-test-renderer": "^16.8.0", | ||
@@ -116,0 +118,0 @@ "react-testing-library": "^6.0.0", |
@@ -130,30 +130,3 @@ # react-fetch-hook | ||
### Paginated requests | ||
```javascript | ||
import React from "react"; | ||
import usePaginatedRequest from "react-fetch-hook/usePaginatedRequest"; | ||
import fetchSomeData from "..." | ||
const Component = () => { | ||
const results = usePaginatedRequest( | ||
({limit, offset}) => fetchSomeData(limit, offset), | ||
20 | ||
); | ||
return ( | ||
<InfiniteScroll | ||
pageStart={0} | ||
loadMore={results.loadMore} | ||
hasMore={results.hasMore} | ||
loader={<div />}> | ||
{results.data && results.data.map((item) => { | ||
... | ||
})} | ||
</InfiniteScroll>) | ||
} | ||
``` | ||
## API | ||
@@ -205,3 +178,5 @@ | ||
### `usePaginatedRequest` | ||
### Experimental: `usePaginatedRequest` | ||
⚠️ Warning: this method is experimental, API can be changed. | ||
Create a paginated request. | ||
@@ -208,0 +183,0 @@ ```javascript |
@@ -7,2 +7,3 @@ var React = require('react') | ||
) { | ||
var depends = Array.prototype.slice.call(arguments, [2]) | ||
var dataState = React.useState([]) | ||
@@ -15,2 +16,8 @@ var currentUpdate = React.useRef() | ||
React.useEffect(function () { | ||
dataState[1]([]) | ||
offsetState[1](0) | ||
hasMoreState[1](true) | ||
}, depends) | ||
React.useEffect( | ||
@@ -34,3 +41,3 @@ function () { | ||
}, | ||
[offsetState[0]] | ||
[offsetState[0]].concat(depends) | ||
) | ||
@@ -37,0 +44,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153
14318
37
197