A performant interface for rendering sectioned lists, supporting the most handy features:
If you don't need section support and want a simpler interface, use
<FlatList>.
If you need sticky section header support, use ListView for now.
Simple Examples:
This is a convenience wrapper around <VirtualizedList>,
and thus inherits the following caveats:
PureComponent which means that it will not re-render if props remain shallow-
equal. Make sure that everything your renderItem function depends on is passed as a prop that
is not === after updates, otherwise your UI may not update on changes. This includes the
data prop and parent component state.key prop on each item and uses that for the React key.
Alternatively, you can provide a custom keyExtractor prop.Rendered in between adjacent Items within each section.
Rendered at the very end of the list.
Rendered at the very beginning of the list.
Rendered in between each section.
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.
How many items to render in the initial batch. This should be enough to fill the screen but not much more. Note these items will never be unmounted as part of the windowed rendering in order to improve perceived performance of scroll-to-top actions.
Used to extract a unique key for a given item at the specified index. Key is used for caching and as the react key to track item re-ordering. The default extractor checks item.key, then falls back to using the index, like react does.
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.
Thus a value of 0.5 will trigger onEndReached when the end of the content is
within half the visible length of the list.
If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make
sure to also set the refreshing prop correctly.
Called when the viewability of rows changes, as defined by the
viewabilityConfig prop.
Set this true while waiting for new data from a refresh.
Default renderer for every item in every section. Can be over-ridden on a per-section basis.
Rendered at the top of each section. Sticky headers are not yet supported.
Makes section headers stick to the top of the screen until the next one pushes it off. Only enabled by default on iOS because that is the platform standard there.
You can edit the content above on GitHub and send us a pull request!
Examples # | Edit on GitHub |