Skip to content

Commit

Permalink
chore: release v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
robcalcroft committed Apr 23, 2020
1 parent c3702e6 commit 2a8e73c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### react-use-infinite-loader is currently in pre release, use with caution

# react-use-infinite-loader :infinity: :page_with_curl: :hourglass_flowing_sand:

> Super lightweight infinite loading hook for React apps
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-use-infinite-loader",
"version": "1.0.0",
"version": "0.0.2",
"description": "Infinitely load new content in React using a simple React hook",
"main": "useInfiniteLoader.es5.js",
"repository": "git@github.com:CurationCorp/react-use-infinite-loader.git",
Expand Down
18 changes: 13 additions & 5 deletions useInfiniteLoader.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ function useInfiniteLoader(_ref) {
_ref$hasMore = _ref.hasMore,
hasMore = _ref$hasMore === void 0 ? false : _ref$hasMore,
_ref$initialise = _ref.initialise,
initialise = _ref$initialise === void 0 ? true : _ref$initialise;
initialise = _ref$initialise === void 0 ? true : _ref$initialise,
_ref$rootMargin = _ref.rootMargin,
rootMargin = _ref$rootMargin === void 0 ? "100px 0px 0px 0px" : _ref$rootMargin,
_ref$threshold = _ref.threshold,
threshold = _ref$threshold === void 0 ? 0 : _ref$threshold;

if (typeof loadMore !== "function") {
throw new TypeError("useInfiniteLoader: loadMore must be a function and is required");
}

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

Expand All @@ -53,8 +61,8 @@ function useInfiniteLoader(_ref) {
loadMore(page.current);
page.current += 1;
}, {
rootMargin: "20px 0px",
threshold: 0.01
rootMargin: rootMargin,
threshold: threshold
});

if (loaderRef.current) {
Expand All @@ -66,10 +74,10 @@ function useInfiniteLoader(_ref) {
observer.current.disconnect();
observer.current = undefined;
};
}, [hasMore, loadMore, page]);
}, [hasMore, loadMore, page, initialise]);

return {
loaderRef: loaderRef,
page: page
page: page.current
};
}

0 comments on commit 2a8e73c

Please sign in to comment.