Skip to content

Commit 2a8e73c

Browse files
committed
chore: release v0.0.2
1 parent c3702e6 commit 2a8e73c

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
### react-use-infinite-loader is currently in pre release, use with caution
2+
13
# react-use-infinite-loader :infinity: :page_with_curl: :hourglass_flowing_sand:
24

35
> Super lightweight infinite loading hook for React apps

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-use-infinite-loader",
3-
"version": "1.0.0",
3+
"version": "0.0.2",
44
"description": "Infinitely load new content in React using a simple React hook",
55
"main": "useInfiniteLoader.es5.js",
66
"repository": "git@github.com:CurationCorp/react-use-infinite-loader.git",

useInfiniteLoader.es5.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ function useInfiniteLoader(_ref) {
2828
_ref$hasMore = _ref.hasMore,
2929
hasMore = _ref$hasMore === void 0 ? false : _ref$hasMore,
3030
_ref$initialise = _ref.initialise,
31-
initialise = _ref$initialise === void 0 ? true : _ref$initialise;
31+
initialise = _ref$initialise === void 0 ? true : _ref$initialise,
32+
_ref$rootMargin = _ref.rootMargin,
33+
rootMargin = _ref$rootMargin === void 0 ? "100px 0px 0px 0px" : _ref$rootMargin,
34+
_ref$threshold = _ref.threshold,
35+
threshold = _ref$threshold === void 0 ? 0 : _ref$threshold;
36+
37+
if (typeof loadMore !== "function") {
38+
throw new TypeError("useInfiniteLoader: loadMore must be a function and is required");
39+
}
3240

3341
var loaderRef = _react.default.useRef(null);
3442

@@ -53,8 +61,8 @@ function useInfiniteLoader(_ref) {
5361
loadMore(page.current);
5462
page.current += 1;
5563
}, {
56-
rootMargin: "20px 0px",
57-
threshold: 0.01
64+
rootMargin: rootMargin,
65+
threshold: threshold
5866
});
5967

6068
if (loaderRef.current) {
@@ -66,10 +74,10 @@ function useInfiniteLoader(_ref) {
6674
observer.current.disconnect();
6775
observer.current = undefined;
6876
};
69-
}, [hasMore, loadMore, page]);
77+
}, [hasMore, loadMore, page, initialise]);
7078

7179
return {
7280
loaderRef: loaderRef,
73-
page: page
81+
page: page.current
7482
};
7583
}

0 commit comments

Comments
 (0)