-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
- I have reviewed the documentation
- I have searched existing issues
- I am using the latest React Native version
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);
}}
/>
);
}