React-native: [FlatList] FlatList onEndReached no work android

Created on 3 Jun 2017  路  18Comments  路  Source: facebook/react-native

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

Stale

Most helpful comment

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.

All 18 comments

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.

+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.

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.

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.

same issue

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

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

+1 same for me

+1

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!

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

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.

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.

I have a same problem.

Still not fixed. Same problem here on Android.

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

+1

[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

Was this page helpful?
0 / 5 - 0 ratings