Skip to content
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] FlatList onEndReached no work android #14312

Closed
KeyX-y opened this issue Jun 3, 2017 · 18 comments
Closed

[FlatList] FlatList onEndReached no work android #14312

KeyX-y opened this issue Jun 3, 2017 · 18 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@KeyX-y
Copy link

KeyX-y commented Jun 3, 2017

<FlatList
data={dataSource}
keyExtractor={(_, i) => i}
ItemSeparatorComponent={this._renderSeparator}
renderItem={({ item }) => this._renderListItem(item)}
onRefresh={() => this.handleRefresh()}
refreshing={refreshing}
onEndReached={() => this.handleLoadMore()}
onEndReachedThreshold={0.3}
/>

this is no work in android,
can work in ios

@shergin
Copy link
Contributor

shergin commented Jun 3, 2017

Can you provide a minimal amount of code to reproduce this using Sketch? This is necessary for people to be able to see and debug the issue being reported.

@hramos hramos changed the title FlatList onEndReached no work android [FlatList] FlatList onEndReached no work android Jun 3, 2017
@PauloDurrerMelo
Copy link

+1

onEndReached is called one or two times before the first load ends and data array is filled.
It should only get called when the data is loaded and the onEndReachedThreshold is true. Since no data is yet displayed, the onEndReached should not be called.

This does not happen on iOS.

@BouncyLlama
Copy link

I'm having this issue as well; onEndReached simply never fires. Here's a link to a sketch that reproduces the issue on android: https://snack.expo.io/SkNo3vn7-

Very frustrating; haven't even been able to find a functional workaround.

@iainheng
Copy link

I had the same problem with onEndReached is not called on Android when FlatList is scrolled to the bottom when I have prop onEndReachedThreshold={0}. Change the {0} to any number greater than 0 will make it working again.

This issue only happen on Android but not iOS.

@yash2code
Copy link

same issue

@zakster12
Copy link

zakster12 commented Jul 17, 2017

Same problem here. Changing the value of onEndReachedThreshold didn't fix the issue.

@vvavepacket
Copy link

+1, happening on android on react native 0.45 any solution?

@vishnuc
Copy link

vishnuc commented Aug 6, 2017

+1 same for me

@phumaster
Copy link

+1

@phumaster
Copy link

I think this is not a bug. My FlatList trigger onEndReached once time. This is problem. When onEndReached trigger, we must get new data and append to the old data => FlatList change and onEndReached can be fire.
My emulator: Pixel_API_25(AVD) - 7.1.1.
React native: 0.46.1.
Worked!

@yash2code
Copy link

@phumaster can you explain with sharing some code. Ty!

@phumaster
Copy link

My FlatList

<FlatList
                    data={this.props.data.data}
                    renderItem={this.renderItem}
                    keyExtractor={this.keyExtractor}
                    initialNumToRender={10}
                    onEndReached={this.handleOnEndReached}
                    onEndReachedThreshold={0.5}
                    refreshing={fetching}
                    onRefresh={this.handleOnRefresh}
                />

I get data. => FlatList have 10 Items

when onEndReached fire i get data from api. Then I change data in reducer (I use Redux)

let {data} = action.payload;
            let hasData = data && data.results && data.results.length > 0;
            state = {
                ...state,
                fetched: true,
                fetching: false,
                data: hasData ? {data: [...state.data.data, ...data.results], nextPage: data.next_page} : {
                    data: [],
                    nextPage: -1
                }
            };

=> FlatList has 20 Items. And onEndReached work!

state.data.data is old data.

@stale
Copy link

stale bot commented Oct 21, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 21, 2017
@stale stale bot closed this as completed Oct 28, 2017
@zhy8023
Copy link

zhy8023 commented Dec 7, 2017

I have a same problem.

@dan-klasson
Copy link

Still not fixed. Same problem here on Android.

@Sadanandteggi
Copy link

I found answer here , I initially tried all solutions given in github comments nothing worked, but finally check this answer which worked for me. Hope it will work for other too.

https://stackoverflow.com/questions/48740770/react-native-flatlist-pagination-not-working-onendreached-doesnt-fired/48747461#48747461

@lucaslz2020
Copy link

+1

@khanhtdbse
Copy link

khanhtdbse commented Mar 27, 2018

[RN 0.52.1 -Both iOS - Android]
In my case onEndReached was not called because the list is not long enough.
So i hacked by adding marginTop to the container of FlatList. After the first fetch i remove that marginTop and anything work as expected

@facebook facebook locked and limited conversation to collaborators May 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests