There is a common problem while working with FlatList pagination. It calls two times with out any reason. We can solve it in different ways.But I have a very effect way which is worked for me.
Try to implement
onMomentumScrollBegin
on FlatList
:constructor(props) {
super(props);
this.onEndReachedCalledDuringMomentum = true;
}
<FlatList
...
onEndReached={this.onEndReached.bind(this)}
onEndReachedThreshold={0.5}
onMomentumScrollBegin={() => { this.onEndReachedCalledDuringMomentum = false; }}
/>
and modify your onEndReached
onEndReached = ({ distanceFromEnd }) => {
if(!this.onEndReachedCalledDuringMomentum){
this.fetchData();
this.onEndReachedCalledDuringMomentum = true;
}
}