使用 flatlist 响应原生无限滚动 [英] React native infinite scroll with flatlist

查看:64
本文介绍了使用 flatlist 响应原生无限滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了本教程https://www.youtube.com/watch?v=rY0braBBlgw当我向下滚动时,它会发送请求,然后它会陷入循环,只是请求和请求.我认为这是列表视图中滚动视图的问题.

I followed this tutorial https://www.youtube.com/watch?v=rY0braBBlgw When I scroll down it sends the request then it gets stuck in a loop and just requests and requests. I think this is a problem with the scrollview in the listview.

推荐答案

我不确定你是否能够解决这个问题,但我遇到了同样的问题,我正在添加对我有用的东西.

I am not sure if you were able to resolve this but I was having the same problem and I am adding what worked well for me.

onEndReachedThreshold=>onEndThreshold

<FlatList
      data={this.state.data}
      renderItem={({ item }) => (
        <ListItem
          roundAvatar
          title={
            <Text style={{textAlign: 'left'}}> {item.name.first} {item.name.last}</Text>
          }
          subtitle={
              <Text style={{textAlign: 'left'}}>{item.email}</Text>
          }
          avatar={{ uri: item.picture.thumbnail }}
          containerStyle={{ borderBottomWidth: 0 }}
        />
      )}
      ItemSeparatorComponent={this.renderSeparator}
      ListHeaderComponent={this.renderHeader}
      ListFooterComponent={this.renderFooter}
      keyExtractor={item => item.email}
      refreshing={this.state.refreshing}
      onRefresh={this.handleRefresh}
      onEndReached={this.handleLoadMore}
      onEndThreshold={0}

    />

我希望这对某人有所帮助.

I hope this helps someone.

这篇关于使用 flatlist 响应原生无限滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆