2017-04-22 2 views
0

documentation에 따르면 ListView의 onLoadMore() 콜백은 "ListView가 첫 페이지의 맨 아래로 끝까지 스크롤 될 때"트리거되어야합니다.Shoutem ListView - onLoadMore가로드를 중지하지 않습니다.

다음 구현이 있는데 문제는 ListView가 페이지를 스크롤하지 않고도 onLoadMore 콜백 호출을 중지하지 않는다는 것입니다. 이것은보기가 잠시 열렸을 때 응답이 없으면 많은 양의 데이터를로드하기 때문에 수용 가능한 솔루션이 아닙니다.

코드는 다음과 같습니다 : 당신이 안에있는 ScrollView 당신의 ListView가있는 경우

<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

, 그것을 밖으로 이동합니다. 이 시나리오에서 RN의 onEndReached 콜백과 관련된 알려진 문제점입니다.

+0

내 문제가 해결되었습니다. ScrollView 안에 ListView가 있습니다. –

관련 문제