From 7979875485393fa1e1b0d12936cf32c7d15ec2d8 Mon Sep 17 00:00:00 2001 From: PierreGUI Date: Thu, 8 Mar 2018 12:40:30 +0100 Subject: [PATCH 1/2] Detach scroll listeners on hasMore prop change Fix #44 --- src/InfiniteScroll.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/InfiniteScroll.js b/src/InfiniteScroll.js index b94c8e4..e27dc8c 100644 --- a/src/InfiniteScroll.js +++ b/src/InfiniteScroll.js @@ -46,6 +46,13 @@ export default class InfiniteScroll extends Component { this.attachScrollListener(); } + componentWillReceiveProps(nextProps) { + if (nextProps.hasMore === false) { + this.detachScrollListener(); + this.detachMousewheelListener(); + } + } + componentWillUnmount() { this.detachScrollListener(); this.detachMousewheelListener(); From ed6d4a8ffb43c9fed5987e6ebb8a3b175b013977 Mon Sep 17 00:00:00 2001 From: PierreGUI Date: Thu, 8 Mar 2018 12:47:29 +0100 Subject: [PATCH 2/2] Build dist file --- dist/InfiniteScroll.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dist/InfiniteScroll.js b/dist/InfiniteScroll.js index 6a7e623..9a90c18 100644 --- a/dist/InfiniteScroll.js +++ b/dist/InfiniteScroll.js @@ -113,6 +113,15 @@ var InfiniteScroll = (function(_Component) { this.attachScrollListener(); }, }, + { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(nextProps) { + if (nextProps.hasMore === false) { + this.detachScrollListener(); + this.detachMousewheelListener(); + } + }, + }, { key: 'componentWillUnmount', value: function componentWillUnmount() {