From a68a56cfee85d859cb965b8153380c350bde8786 Mon Sep 17 00:00:00 2001 From: ajithbhat Date: Wed, 24 Jul 2019 15:34:04 +0100 Subject: [PATCH] check if hasMore before trying to load more results --- dist/InfiniteScroll.js | 2 +- src/InfiniteScroll.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/InfiniteScroll.js b/dist/InfiniteScroll.js index 5bb22a3..a19b049 100644 --- a/dist/InfiniteScroll.js +++ b/dist/InfiniteScroll.js @@ -309,7 +309,7 @@ var InfiniteScroll = (function(_Component) { this.beforeScrollHeight = parentNode.scrollHeight; this.beforeScrollTop = parentNode.scrollTop; // Call loadMore after detachScrollListener to allow for non-async loadMore functions - if (typeof this.props.loadMore === 'function') { + if (this.props.hasMore && typeof this.props.loadMore === 'function') { this.props.loadMore((this.pageLoaded += 1)); this.loadMore = true; } diff --git a/src/InfiniteScroll.js b/src/InfiniteScroll.js index b08637e..d8c8a8c 100644 --- a/src/InfiniteScroll.js +++ b/src/InfiniteScroll.js @@ -216,7 +216,7 @@ export default class InfiniteScroll extends Component { this.beforeScrollHeight = parentNode.scrollHeight; this.beforeScrollTop = parentNode.scrollTop; // Call loadMore after detachScrollListener to allow for non-async loadMore functions - if (typeof this.props.loadMore === 'function') { + if (this.props.hasMore && typeof this.props.loadMore === 'function') { this.props.loadMore((this.pageLoaded += 1)); this.loadMore = true; }