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.?ReactClass<any> #Rendered in between adjacent Items within each section.
?ReactClass<any> #Rendered at the very end of the list.
?ReactClass<any> #Rendered at the very beginning of the list.
?ReactClass<any> #Rendered in between each section.
(item: Item, index: number) => string #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.
?(info: {distanceFromEnd: number}) => void #?() => void #If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make
sure to also set the refreshing prop correctly.
?(info: {viewableItems: Array<ViewToken>, changed: Array<ViewToken>}) => void #Called when the viewability of rows changes, as defined by the
viewabilityConfig prop.
?boolean #Set this true while waiting for new data from a refresh.
(info: {item: Item, index: number}) => ?React.Element<any> #Default renderer for every item in every section. Can be over-ridden on a per-section basis.
?(info: {section: SectionT}) => ?React.Element<any> #Rendered at the top of each section. Sticky headers are not yet supported.
Array<SectionT> #(
prevProps: {item: Item, index: number},
nextProps: {item: Item, index: number}
) => boolean #This is an optional optimization to minimize re-rendering items.
You can edit the content above on GitHub and send us a pull request!
Examples # | Edit on GitHub |