Skip to content

FlatList onEndReached can not be called! #25656

@luoyushouchai

Description

@luoyushouchai

React Native version: 0.59.9

Steps To Reproduce

I console log in VirtualizedLIst. The function _maybeCallOnEndReached() called.

_maybeCallOnEndReached() {
 const {
   data,
   getItemCount,
   onEndReached,
   onEndReachedThreshold,
 } = this.props;
 const {contentLength, visibleLength, offset} = this._scrollMetrics;
 const distanceFromEnd = contentLength - visibleLength - offset;
 if (
   onEndReached &&
   this.state.last === getItemCount(data) - 1 &&
   /* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses an
    * error found when Flow v0.63 was deployed. To see the error delete this
    * comment and run Flow. */
   distanceFromEnd < onEndReachedThreshold * visibleLength &&
   (this._hasDataChangedSinceEndReached ||
     this._scrollMetrics.contentLength !== this._sentEndForContentLength)
 ) {
   // Only call onEndReached once for a given dataset + content length.
   this._hasDataChangedSinceEndReached = false;
   this._sentEndForContentLength = this._scrollMetrics.contentLength;
   onEndReached({distanceFromEnd});
 }
}

console result: this.state.last = 0; getItemCount(data) = 2;
this.state.last !== getItemCount(data) -1 , so can not trigger onEndReached!

But for FlatList, it has reach end!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugComponent: FlatListStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions