2017-04-22 14 views
0

documentationによれば、ListViewのonLoadMore()コールバックは、 "ListViewが最初のページの最後までスクロールされている"場合にのみ呼び出されます。Shoutem ListView - onLoadMoreは読み込みを停止しません

私は次の実装をしています。問題は、ListViewがページをスクロールせずにonLoadMoreコールバックの呼び出しを停止しないことです。これは許容される解決策ではありません。なぜなら、ビューがしばらく開いているときにデータが非常に読み込まれ、応答が無くなるからです。

コードは、次のようになります。

<ListView 
    data={this.state.posts} 
    renderRow={this.renderRow} 
    loading={this.state.loading} 
    onLoadMore={this.onFeedLoadMore} 
/> 

...

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); 
     }) 
     } 
} 

答えて

1

あなたがScrollView内のあなたのリストビューを持っている場合は、それを動かします。このシナリオでは、RNのonEndReachedコールバックに関する既知の問題です。

+0

それは私の問題を解決しました。私はリストビューをScrollView内に持っていた –

関連する問題