FlatList onEndReached can not be called!
See original GitHub issueReact 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!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:31 (1 by maintainers)
Top Results From Across the Web
ReactNative Flatlist onEndReached not working
I'm calling the this.state.pageNo at the end and it's not updating. I want to use this logic later in infinite scroll but not...
Read more >Unable to render data to ReactNative FlatList on Scroll down ...
I am using FlatList's onEndReached prop to get new items on scroll ... Warning: Can't perform a React state update on an unmounted...
Read more >onEndReached not working : r/reactnative - Reddit
Hello guys, I successfully implemented the API with pagination in app using FlatList. It successfully calls the next page on reaching the ...
Read more >FlatList onEndReached Called On Load [iOS] - Expo Snack
FlatList onEndReached Called On Load [iOS]. No description. Open with Expo Go. Open in editor. Need Expo? Don't have the Expo Go?
Read more >FlatList onEndReached being called multiple times-React Native
Coding example for the question FlatList onEndReached being called multiple times-React Native. ... onEndReached trigger is not being called in FlatList ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
@JerakRus @luoyushouchai @e1016 Hi guys 😃 good news, well the solution was envolved flatList into View and set height (const {height} = Dimensions.get(‘window’);) to view, percent not work:
And if this not scroll envolved into ScrollView: ScrollView -> View (height) -> FlatList
0.61.3 still happening …