Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,21 @@ export default class InfiniteScroll extends Component<Props, State> {
// 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) {
Expand Down