首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Shoutem ListView - onLoadMore不停止加载

Shoutem ListView - onLoadMore不停止加载
EN

Stack Overflow用户
提问于 2017-04-22 20:03:34
回答 1查看 228关注 0票数 0

根据文档,ListView的onLoadMore()回调只能在“ListView一直滚动到第一页底部”时触发。

我确实有以下实现,问题是,即使没有向下滚动页面,ListView也不会停止调用onLoadMore回调。这不是一个可接受的解决方案,因为当视图打开一段时间时,它只是加载了大量数据,从而导致响应迟钝。

代码如下所示:

代码语言:javascript
复制
<ListView
    data={this.state.posts}
    renderRow={this.renderRow}
    loading={this.state.loading}
    onLoadMore={this.onFeedLoadMore}
/>

..。

代码语言:javascript
复制
onFeedLoadMore() {
      console.log("onFeedLoadMore called");

      this.setState({loading: true});

      if (_.has(this.state.paging, 'next')) {
        fetch(this.state.paging.next, {
          method: 'GET',
          headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json',
          }
        }).then((response) => response.json()).then((responseJson) => {
          this.setState({loading: false});
          console.log(responseJson);

          this.setState({paging: responseJson.paging});
          this.setState({posts: this.state.posts.concat(responseJson.data)})

        }).catch((error) => {
          this.setState({loading: false});
          console.log("error fetching paged fb newsfeed: ", error);
        })
      }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-22 20:42:37

如果您的ListView在ScrollView中,请将其移出。这是RN在这个场景中的onEndReached回调中的一个已知问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43564021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档