React Native 无限滚动问题,元素很少
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
也有不同的机制)
我正在使用 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
也有不同的机制)