我的容器是一个滚动视图,里面是一个扁平列表,它从服务器加载数据。
扁平表:
<VirtualizedList
ListEmptyComponent={<NoData />}
data={data}
getItem={(items, index) => items.get(index)}
getItemCount={(items) => items.size}
keyExtractor={(item, index) => String(index)}
renderItem={this._renderItem}
refreshControl={
<RefreshControl
refreshing={loading}
onRefresh={this._onRefresh.bind(this)}
/>
}
onEndReached={this.handleLoadMore}
onEndReachedThreshold={0.1}
onMomentumScrollBegin={() => {
Log('onMomentumScrollBegin fired!')
this.onEndReachedCalledDuringMomentum = false;
}}
/>
哪个handleLoadMore
是:
handleLoadMore = () => {
Log('handleLoadMore fired!');
if (!this.onEndReachedCalledDuringMomentum) {
// fetch data..
this.onEndReachedCalledDuringMomentum = true;
}
}
问题是handleLoadMore
从未调用,onMomentumScrollBegin
也从未调用过。
如何解决这个问题?
发布于 2019-08-22 15:04:34
实际上,您不需要使用Content
或ScrollView
,因为FlatList同时具有ListFooterComponent
和ListHeaderComponent
如果您确实需要在ScrollView
中使用FlatList,则可以将样式和内容contentContainerStyle添加到ScrollView
中,或者,如果您使用本机基础,请在Content
中添加样式和内容use
<ScrollView
...
style={{flex: 1}}
contentContainerStyle={{flex: 1}}
...
/>
然后,如果你想在FlatList循环之外使用头组件。然后在平面列表中使用ListHeaderComponent={() => <SomeHeader />
。
https://stackoverflow.com/questions/51319922
复制相似问题