How to optimize performance of Flatlist when we have large data.
My list has both an image and an text description.
I want to find a way to increase performance of list and remove extra images loaded from the cache list and make the list not heavy.
My list has both an image and an text description.
I want to find a way to increase performance of list and remove extra images loaded from the cache list and make the list not heavy.
The FlatList component is supposed to be a performant solution for displaying large lists of data in your app. It only displays some of the items in the list according to which items are currently visible. That said there are a few tricks that help to make it faster / lighter
I'm sure there are more things you can do, but that's it from me :)
There is something called PureComponent in react native. If you create your FlatList item as PureComponent, you can see lot of improvement. It will not rerender items untill data has been changed.
Something like this :
class MyListItem extends React.PureComponent {
}
Even the library suggested by Nino9612 react-native-optimized-flatlist is also using the same concept, as you can see code of their FlatListItem
There are multiple npm packages promising to improve the performance of the default react-native flatlist for example https://www.npmjs.com/package/recyclerlistview#demo or https://github.com/stoffern/react-native-optimized-flatlist . I didnt test them but they seem to improve the overall performance. If you not working with local data but with data you receive from a network maybe you should take a look into pagination to improve the list speed and also (mobile) data usage