Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between ListView and FlatList?

Tags:

According to Facebook's documentation,

ListView - A core component designed for efficient display of vertically scrolling lists of changing data.

FlatList - A performant interface for rendering simple, flat lists.

It seems both are efficient. What should we consider when choosing one from the other?

like image 824
C.Lee Avatar asked Jun 12 '17 23:06

C.Lee


People also ask

What is difference between SectionList and FlatList in React Native?

SectionList s are like FlatList s, but they can have section headers to separate groups of rows. SectionList s render each item in their input sections using the renderSectionHeader and renderItem prop. Each item in sections should be an object with a unique id (the key), and an array data of row data.

What is FlatList used for?

FlatList is used to render the items in a scrollable list view. Large Data: When we have a large list of data and the number of data can change over time we can use FlatList as large data affect rendering speed and using FlatList won't affect the rendering speed.

What is ListView in React Native?

React Native ListView is a view component which contains the list of items and displays in a vertical scrollable list. The minimum API to create list view is ListView. DataSource. It populates a simple array of data blobs, and instantiate a ListView component with data source and a renderRow callback.


1 Answers

FlatList - More performant compared to ListView. ListView rendering can get slow once the number of items grows larger. FlatList significantly improves memory usage and efficiency (especially for large or complex lists) while also significantly simplifying the props — no more dataSource necessary!

Features
Flatlist is packed with new components full of features to handle the majority of use cases out of the box:

  • Scroll loading (onEndReached).
  • Pull to refresh (onRefresh / refreshing).
  • Configurable viewability (VPV) callbacks (onViewableItemsChanged / viewabilityConfig).
  • Horizontal mode (horizontal).
  • Intelligent item and section separators.
  • Multi-column support (numColumns)
  • scrollToEnd, scrollToIndex, and scrollToItem
  • Better Flow typing.

FlatList is still missing some features, like sticky headers, but it's evolving fast. ListView is going to get deprecated.

ListView is deprecated now and Sticky Headers in Flat list working now

Better options out there

I was getting performance issues while rendering 5000+ items in flat-list. Looked for other alternatives and found recyclerlistview - High performance list-view for React Native and web. Much better scrollTo performance and better rendering optimisations compared to flat-list.

like image 171
Victor Avatar answered Sep 17 '22 13:09

Victor