[英]React Native Flatlist - VirtualizedList: You have a large list that is slow to update
I have a flat list with large content and when I am scrolling down after 10 - 15 pages on debugger console i have getting this: 我有一个包含大量内容的平面列表,当我在调试器控制台上10-15页后向下滚动时,我得到了这个:
VirtualizedList: You have a large list that is slow to update - make sure your renderItem function renders components that follow React performance best practices like PureComponent, shouldComponentUpdate, etc. {dt: 582, prevDt: 1651, contentLength: 15187.5}
VirtualizedList:你有一个很快更新的大型列表 - 确保你的renderItem函数呈现遵循React性能最佳实践的组件,如PureComponent,shouldComponentUpdate等。{dt:582,prevDt:1651,contentLength:15187.5}
FYI: I have tried to use PureComponent and more ways but no one is helpful I am getting the same output in console. 仅供参考:我曾尝试使用PureComponent和更多方法,但没有人有用我在控制台中获得相同的输出。
Why I am getting this and how can solve this? 为什么我得到这个以及如何解决这个问题?
This is my code : 这是我的代码:
<FlatList
data={outfits}
keyExtractor={(item, index) => index}
numColumns={2}
initialNumToRender={5}
getItemLayout={(outfits, index) => (
{ length: 50, offset: 50 * index, index }
)}
extraData={this.state.extraData}
renderItem={({item,index}) => <Items item={item} index={index}/>}
onRefresh={this.handleRefresh}
refreshing={this.state.refreshing}
onEndReached={this.handleLoadMore}
onEndReachedThreshold={20}
ListFooterComponent={this.renderFooter}
/>
I had the same issue with Content
in https://docs.nativebase.io and I changed Content
to View
and used PureComponent
. 我在https://docs.nativebase.io中遇到了与
Content
相同的问题,我将Content
更改为View
并使用了PureComponent
。 And now it's work! 而现在它的工作!
please use RefreshControl and props refresh control in Content native base 请在内容本机库中使用RefreshControl和props刷新控件
import { StyleSheet, RefreshControl } from 'react-native';
...
render(
<Content refreshControl={<RefreshControl refreshing={this.state.refreshing} onRefresh={this._onRefresh.bind(this)} />}>
<List .../>
</Content>
...
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.