简体   繁体   中英

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:

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}

FYI: I have tried to use PureComponent and more ways but no one is helpful I am getting the same output in console.

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 . And now it's work!

please use RefreshControl and props refresh control in Content native base

 import { StyleSheet, RefreshControl } from 'react-native';

...
render(
  <Content refreshControl={<RefreshControl refreshing={this.state.refreshing} onRefresh={this._onRefresh.bind(this)} />}>
       <List .../>
      </Content>
...
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM