在加载时调用onEndReach

时间:2018-09-05 13:49:16

标签: react-native react-native-flatlist

我正在使用Flatlist并尝试添加分页。 我已经为onEndReachedThreshold尝试了很多数字,但是每次在加载时调用onEndReached。

这是我的代码:

        <FlatList
      data={props.notifications}
      renderItem={renderNotification}
      keyExtractor={(item, index) => index.toString()}
      style={styles.container}
      refreshing={false}
      onRefresh={props.reloadNotifications}
      onMomentumScrollBegin={() => {
        this.onEndReachedCalledDuringMomentum = false;
      }}
      onEndReachedThreshold={0.2}
      onEndReached={() => {
        if (!this.onEndReachedCalledDuringMomentum) {
          props.loadMoreNotifications();
          console.log('load more called');
          this.onEndReachedCalledDuringMomentum = true;
        }
      }}
    />

0 个答案:

没有答案