2017-09-22 111 views
4

如果我將平面列表放在View中,那麼我的onEndReached無限觸發,如果我刪除封閉的View onEndReached根本不會觸發。onEndReached在Flatlist問題

render(){ 

    return (
     <Root> 
      <Container> 
        <Content>     
         <View> 
           {this.state.listView && 
            <FlatList 
            data={this.state.variants} 
            keyExtractor={this._keyExtractor} 
            onEndReachedThreshold={0.5} 
            onEndReached={({ distanceFromEnd }) => { 
             console.log('on end reached ', distanceFromEnd); 
             this.loadMore(); 
            }} 
            numColumns = {1} 
            renderItem={({item, index}) =><CatalogRow item={item} in_wishlist={this.state.in_wishlist} toggleWishlist={() => this.toggleWishlist(item.title)} listView={this.state.listView}/>} 
           />} 

          </View> 
        </Content> 
       </Container> 
      </Root> 
    ); 
    } 

而且我distanceFromEnd當trigerred需要像0,960,1200值。它表明什麼? 我使用的反應本地0.47.2

+0

我不認爲你的代碼中有任何錯誤。只要嘗試更新您的反應原生版本以最新並檢查。它們的實現中可能存在一個錯誤,它將在最新版本中修復。 –

+0

好吧謝謝你會檢查:) – subha

回答

2

這是怎麼一回事,因爲封閉<Content>標籤。有時將native-base標籤嵌入react-native標籤會導致此類問題。我用View標籤替換了內容和容器標籤,現在它工作正常。

0

我會用這樣的:

handleMore =() => { 
    // fetch more here 
}; 

<FlatList 
    onEndReached={this.handleMore} 
/>