From 51937f7347a276c1ab690b0c57a15e8d523d7f0e Mon Sep 17 00:00:00 2001 From: ardeshir Date: Mon, 1 May 2023 14:45:18 +0000 Subject: [PATCH] fix long screen issue --- src/index.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 2782fbb..586883d 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 > 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) {