-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FlatList] onEndReached triggered 2 times #14015
Comments
mine doesn't even trigger. |
@parkerproject |
@fengshanjian
|
Same issue my side. Seems to be a bug in the ScrollView bouncing feature on iOS (when you over scroll on iOS the ScrollView scrolls past the content and bounces back to the end of the content by default). Setting |
Hey, thanks for reporting this issue! It looks like your description is missing some necessary information. Can you please add all the details specified in the template? This is necessary for people to be able to understand and reproduce the issue being reported. |
I'm definitely seeing the second |
OK, here is my solution for how to avoid the second
<FlatList
data={this.props.data}
onEndReached={...}
onEndReachedThreshold={0.5}
...
onMomentumScrollBegin={() => { this.onEndReachedCalledDuringMomentum = false; }}
/>
onEndReached = () => {
if (!this.onEndReachedCalledDuringMomentum) {
this.props.fetchData();
this.onEndReachedCalledDuringMomentum = true;
}
}; Tested with RN 0.44.0. |
hi @grin can you pls refer me some document about the function onMomentumScrollBegin? i cannot find any on http://facebook.github.io/react-native/releases/0.46/docs/flatlist.html |
@gonglong you can find information about props here https://github.com/facebook/react-native/blob/master/Libraries/Components/ScrollView/ScrollView.js#L246 |
FlatList is just wrapper of the ScrollView |
Hey, thanks for reporting this issue! It looks like your description is missing some necessary information, or the list of reproduction steps is not complete. Can you please add all the details specified in the template? This is necessary for people to be able to understand and reproduce the issue being reported. I am going to close this, but feel free to open a new issue with the additional information provided. Thanks! |
many thanks @grin. i faced with multiple call onEndReached and your solution decrease my api call by 2. I fixed it by adding load state validation: |
@ezha86 Can you look at the code? |
I've been having a couple different issues with onEndReached. I recently created an issue with a very detailed breakdown of everything here: #16067. Hope this is helpful to someone. |
My react-native version is 0.44
when you drag list to bottom , you will see log below.
so , my solution is do something in
dose someone kowns the reason ? |
@grin solution is good, but when the data is small, there is no scroll bar, it still triggered my My solution:
May be it is not a good solution, but works fine in my scenario. For reference only |
Try this |
Tried all the above mentioned solution, nothing helped. Still facing this multiple call issue in IOS & Android. |
Was also happening with me, try keeping a flag to stop making request.
Then I set the state to loading false after completing of request |
`constructor(props){ _scrolled(){ loadMore = () => { //you can now load more data here from your backend
<FlatList
` |
|
using |
@gougoushan Not working for me |
don't use onEndReached
|
@GaoYuJian You are a hero!! |
This is my solution:
|
For some reasons my |
I have solved it with using debounce from lodash first and then just add this to your
|
Is this going to be fixed in the next release or is the hack necessary? |
<FlatList
ref={(flatList)=>this._flatList = flatList}
ListHeaderComponent={this._header}
ListFooterComponent={this._footer}
ItemSeparatorComponent={this._separator}
renderItem={this._renderItem}
getItemLayout={(data,index)=>({length: ITEM_HEIGHT, offset: (ITEM_HEIGHT+2) * index, index})}
onEndReachedThreshold={0.5}
onEndReached={(info)=>{
console.log(JSON.stringify(info));
}}
data={data}
/>
When the scroll speed is fast enough,onEndReached triggered 2 times or more times
Is there any solution?
The text was updated successfully, but these errors were encountered: