FlatList onEndReached triggered before reach onEndReachedThreshold
See original GitHub issueDescription
FlatList
onEndReached
triggered before reach end of list. If legacyImplementation
is set to true or render with ListView
, onEndReached
will trigger correctly when it reached end of list
Reproduction
Based from FlatListExample on UIExplorer in React Native v0.43.0-rc.1, add onEndReached
to FlatList
state = {
data: genItemData(30),
debug: false,
horizontal: false,
filterText: '',
fixedHeight: true,
logViewable: false,
virtualized: true,
};
<FlatList
HeaderComponent={HeaderComponent}
FooterComponent={FooterComponent}
SeparatorComponent={SeparatorComponent}
data={filteredData}
debug={this.state.debug}
disableVirtualization={!this.state.virtualized}
getItemLayout={this.state.fixedHeight ?
this._getItemLayout :
undefined
}
horizontal={this.state.horizontal}
key={(this.state.horizontal ? 'h' : 'v') +
(this.state.fixedHeight ? 'f' : 'd')
}
legacyImplementation={false}
numColumns={1}
onRefresh={this._onRefresh}
onViewableItemsChanged={this._onViewableItemsChanged}
ref={this._captureRef}
refreshing={false}
renderItem={this._renderItemComponent}
shouldItemUpdate={this._shouldItemUpdate}
viewabilityConfig={VIEWABILITY_CONFIG}
onEndReachedThreshold={1}
onEndReached={({ distanceFromEnd }) => {
console.log('on end reached ', distanceFromEnd)
}}
/>
Additional Information
- React Native version: v0.43.0-rc.1
- Platform: Both
- Operating System: MacOS
Issue Analytics
- State:
- Created 7 years ago
- Reactions:16
- Comments:40 (5 by maintainers)
Top Results From Across the Web
react native - FlatList calls `onEndReached` when it's rendered
But my problem is onEndReached is called when render() is called In other words, FlatList's onEndReached is triggered before it reach the bottom....
Read more >FlatList - React Native
Thus a value of 0.5 will trigger onEndReached when the end of the content is within half the visible length of the list....
Read more >How it works | React Native Bidirectional Infinite Scroll
You can add a prop onEndReached on FlatList . This function gets called when your scroll is near the end of the list,...
Read more >flatlist onendreached not working
onEndReached is called one or two times before the first load ends and data array is filled. ... onendreachedthreshold flatlist not working.
Read more >React Native — Infinite Scroll Pagination with FlatList
onEndReachedThreshold is used to determine how far the distance from the bottom in order to trigger onEndReached . The smaller the threshold, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe Content is from NativeBase and I believe that implements a ScrollView. FlatList cannot work right inside a ScrollView.
I know how to solve this, you just need to set onEndReachedThreshold as a rate of visibleLength. So you just need to set it as a number smaller than 1, then it worked!!!