Skip to content

Commit

Permalink
Detach scroll listeners on hasMore prop change
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreGUI committed Mar 8, 2018
1 parent 179e3a6 commit 22627ff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/InfiniteScroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export default class InfiniteScroll extends Component {
this.attachScrollListener();
}

componentWillReceiveProps(nextProps) {
if (nextProps.hasMore === false) {
this.detachMousewheelListener();
}
}

componentWillUnmount() {
this.detachScrollListener();
this.detachMousewheelListener();
Expand Down

0 comments on commit 22627ff

Please sign in to comment.