我正在使用 React Native 和 Firebase,并且尝试在 ListView 上使用无限滚动(加载更多),如果第一次获取可以填充屏幕整个高度的列表,则一切正常,因为 onEndReached 是触发,但是当元素很少并且屏幕上根本没有填充 ListView 时, 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
机制)
关于javascript - React Native 无限滚动问题与少数元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49937122/