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() { 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();