1
votes

I have FlatList inside ScrollView, FlatList has onEndReached method to load paginated data (onEndReachedThreshold set to 0.1).The problem that onEndReached method keeps triggering without even scrolling.

<FlatList
  nestedScrollEnabled={true}
  removeClippedSubviews
  initialNumToRender={20}
  data={listProducts.items}
  keyExtractor={item => item.id}
  renderItem={({ item }) => (
   <ProductListBlockItem
     icon="gerkules"
     goToProductInfo={goToProductInfo}
     title={item.name}
     price="29.99"
     rating={4}
     textColor={textColor}
     id={item.id}
    />
  )}
  onEndReached={onLoadNext}
  onEndReachedThreshold={0.1}
/>

FlatList in ScrollView, onEndReached should trigger only when I scroll to bottom of the list,

1
Have you tried adding the following to the element wrapping your FlatList: style={{flex: 1}} contentContainerStyle={{flex: 1}}? According to github.com/GeekyAnts/NativeBase/issues/…, this should fix the issue. - Marcel Kalveram

1 Answers

-1
votes

onEndReached is buggy props. Probably still not fixed.

In my case below 'onEndReachedThreshold' values working.

<FlatList
  nestedScrollEnabled={true}
  removeClippedSubviews
  initialNumToRender={20}
  data={listProducts.items}
  keyExtractor={item => item.id}
  onEndReached={onLoadNext}
  onEndReachedThreshold={platform === 'ios' ? 0 : 0.01}
/>