Skip to content

onEndReached callback trigger twice #18887

@tafelito

Description

@tafelito

FlatList onEndReached callback trigger twice sometimes or even 4 times.

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.4
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.54.4 => 0.54.4

Steps to Reproduce

I'm using a FlatList with inverted={true}. I don't have exactly steps to reproduce it as it happens randomly. I saw a bunch of other issues having the same problem but none of them provided a solution. #14015 did not work for me. If I set the onEndReachedThreshold to 0.8 it doesn't happen all the time as opposed as using the default value of 0.5 that makes it happen constantly. I don't think a re-render is causing this either as it's only running once as you can see from the logs.

Expected Behavior

onEndReached to be called once.

Actual Behavior

this is the render method

render() {
    console.log("render messages", this.props.messages);
    return (
      <FlatList
        inverted
        data={this.props.messages}
        keyExtractor={this.keyExtractor}
        renderItem={this.renderItem}
        onEndReached={info => {
          console.log("onEndReached", info);
        }}
      />
    );
  }

And this is the output
image

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