我有一个这样的平面列表:
<AnimatedFlatList
onViewableItemsChanged={({ viewableItems }) =>
console.log("Data: " + JSON.stringify(viewableItems))
}
ref={scrollRef => {
this.scrollRef = scrollRef;
}}
data={this.getDataSource()}
contentContainerStyle={[
!_.isEmpty(this.getPageActions())
? { paddingBottom: this.getScaledHeight(80) }
: {},
this.getContentContainerStyle(),
]}
onScrollToIndexFailed={info => {
const scrollView = this.getScrollViewNode(this.scrollRef);
if (scrollView)
scrollView.scrollToOffset({
offset: info.averageItemLength * info.index,
animated: true,
});
const wait = new Promise(resolve => setTimeout(resolve, 100));
wait.then(() => {
if (scrollView)
scrollView.scrollToIndex({
index: info.index,
animated: true,
});
});
}}
onScroll={this._onScroll}
showsVerticalScrollIndicator={false}
removeClippedSubviews={false}
ListHeaderComponent={this._renderListHeader}
ListFooterComponent={this._renderListFooter}
ItemSeparatorComponent={this._renderDivider}
keyExtractor={this._keyExtractor}
onEndReachedThreshold={0.5}
onEndReached={() => {
if (this.paginationEnabled()) this.onEndReached();
}}
{...this.getlistProps()}
renderItem={this._renderItem}
/>
我已经设置了 onViewableItemsChanged,但是在应用程序启动时,我不断收到错误消息: Flatlist 不支持同时设置 onViewableItemsChanged 和 viewabilityConfigCallbackPairs
我没有看到viewabilityConfigCallbackPairs被设置。所以无法弄清楚这里有什么问题。有人可以帮忙吗?
提前致谢!