ScrollView中的FlatList无法正常工作,即使没有滚动,它也会加载所有分页数据,onEndReached错误

时间:2019-06-18 08:46:14

标签: react-native react-native-flatlist

我在ScrollView中有FlatList,FlatList的onEndReached方法用于加载分页数据(onEndReachedThreshold设置为0.1).onEndReached方法保持触发而不滚动的问题。

<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}
/>

ScrollView中的FlatList,onEndReached仅在我滚动到列表底部时才触发

1 个答案:

答案 0 :(得分:0)

onEndReached是越野车道具。可能仍未解决。

在我的情况下,'onEndReachedThreshold'值有效。

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