diff --git a/src/index.tsx b/src/index.tsx index 2782fbb..0c9915f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -143,12 +143,21 @@ export default class InfiniteScroll extends Component { // do nothing when dataLength is unchanged if (this.props.dataLength === prevProps.dataLength) return; - this.actionTriggered = false; - - // update state when new data was sent in - this.setState({ - showLoader: false, - }); + const fetchAgain = + this._infScroll && + this._scrollableNode && + this._scrollableNode.clientHeight + 300 > this._infScroll.scrollHeight; + if (fetchAgain) { + this.actionTriggered = true; + this.setState({ showLoader: true }); + this.props.next(); + } else { + this.actionTriggered = false; + // update state when new data was sent in + this.setState({ + showLoader: false, + }); + } } static getDerivedStateFromProps(nextProps: Props, prevState: State) {