代码之家  ›  专栏  ›  技术社区  ›  Morton

为什么SectionList onEndReached不起作用?

  •  0
  • Morton  · 技术社区  · 4 年前

    onEndReached <SectionList /> ,但当我滚动到底部时 一次成功 不会再触发了。

    render (
      return (
        <View style={{ flex: 1 }}>
          <SectionList
            style={{ backgroundColor: 'pink' }}
            refreshControl={
              <RefreshControl
                refreshing={false}
                onRefresh={() => console.log('refreshControl')}
                tintColor='gray'
              />
            }
            renderSectionHeader={this.sectionHeader}
            renderItem={this.renderSectionView}
            sections={reservations}
            onEndReachedThreshold={0.05}
            onEndReached={(data) => {
             console.log('data', data); // { distanceFromEnd: -457 }
             console.log('onEndReached');
            }}
            keyExtractor={(item, index) => index}
            ItemSeparatorComponent={() => <View style={{ backgroundColor: 'gray', height: StyleSheet.hairlineWidth }} />}
          />
        </View>
      );
    );
    

    这是我的 <节列表/> 屏幕: enter image description here

    在我的 < refreshControl 很好但是 一次成功

    1 回复  |  直到 4 年前
        1
  •  1
  •   Nooruddin Lakhani    4 年前

    看起来很多人都有同样的经历。建议将onEndReachedThreshold更改为大于0.05的值,例如:0.5