簡體   English   中英

用很少的元素來響應本機無限滾動問題

[英]React Native infinite scroll problems with few elements

我正在將React Native與Firebase一起使用,並且嘗試在Listview上使用無限滾動(加載更多內容),如果第一次提取可以填充整個屏幕高度的列表,則一切正常,因為觸發了onEndReached,但是當元素很少,並且列表視圖在屏幕上根本沒有填充,onEndReached不會觸發,因此它不會下載並填充下一條記錄。 有人可以幫助我處理這種情況嗎? 提前致謝。

return (
        <View style={{flex:1}}>  
            <ListView
                dataSource={this.state.userDataSource}
                renderRow={this.renderRow.bind(this)}
                style={{paddingTop: 10, paddingBottom: 10}}
                enableEmptySections={true}
                renderFooter={this.renderFooter.bind(this)}
                onEndReached={this.infScrollFetch.bind(this)}
                onEndReachedThreshold={0.1}
                refreshControl={
                    <RefreshControl
                        refreshing={this.state.refreshing}
                        onRefresh={this._onRefresh.bind(this)}
                        title="Pull to refresh" tintColor="#fff" titleColor="#fff" colors={["#FEC200"]}
                    />
                }
                />
        </View>
      );

然后在componentDidMount()上調用第一個提取

嘗試使用FlatList- >它是無限列表的最佳元素。 (它對onEndReachedThreshold也有不同的機制)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM