- Fully cross-platform
- Optional horizontal mode
- Configurable viewability callbacks
- Header and footer support
- Separator support
- Pull to refresh
- Scroll loading
- ScrollToIndex support
Example
Props
An array (or array-like list) of items to render.
Takes an item from
data and renders it into the list. Provides additional metadata like index and separators.Used to extract a unique key for a given item at the specified index. The default extractor checks
item.key, then falls back to using the index.Rendered in between each item, but not at the top or bottom.
Rendered at the top of all the items.
Rendered at the bottom of all the items.
Rendered when the list is empty.
A marker property for telling the list to re-render (since it implements
PureComponent). If any of your renderItem, Header, Footer, etc. functions depend on anything outside of the data prop, stick it here and treat it immutably.If true, renders items next to each other horizontally instead of stacked vertically.
Multiple columns can only be rendered with
horizontal={false} and will zig-zag like a flexWrap layout. Items should all be the same height.Optional custom style for multi-item rows generated when
numColumns > 1.How many items to render in the initial batch. This should be enough to fill the screen but not much more.
Instead of starting at the top with the first item, start at
initialScrollIndex. Requires getItemLayout to be implemented.Reverses the direction of scroll. Uses scale transforms of -1.
Called once when the scroll position gets within
onEndReachedThreshold of the rendered content.How far from the end (in units of visible length of the list) the bottom edge of the list must be from the end of the content to trigger the
onEndReached callback.If provided, a standard RefreshControl will be added for “Pull to Refresh” functionality. Make sure to also set the
refreshing prop correctly.Set this true while waiting for new data from a refresh.
An optional optimization that lets us skip measurement of dynamic content if you know the height of items a priori.
getItemLayout is efficient and easy to use if you have fixed height items.This may improve scroll performance for large lists. The default value is true for Android.
See
ViewabilityHelper.js for flow type and further documentation.Called when the viewability of rows changes.
Methods
scrollToEnd()
getItemLayout prop.
scrollToIndex()
scrollToItem()
scrollToIndex instead if possible.
scrollToOffset()
Performance
FlatList is aPureComponent which means it will not re-render if props remain shallow-equal. Make sure to:
- Pass
extraDataif yourrenderItemdepends on external data - Use
keyExtractorto provide stable keys - Implement
getItemLayoutfor fixed-height items - Use
removeClippedSubviewsfor large lists