Base implementation for the more convenient <FlatList>
and <SectionList>
components, which are also better
documented. In general, this should only really be used if you need more flexibility than
FlatList
provides, e.g. for use with immutable data instead of plain arrays.
Virtualization massively improves memory consumption and performance of large lists by maintaining a finite render window of active items and replacing all items outside of the render window with appropriately sized blank space. The window adapts to scrolling behavior, and items are rendered incrementally with low-pri (after any running interactions) if they are far from the visible area, or with hi-pri otherwise to minimize the potential of seeing blank space.
Some 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
(e.g. extraData
) 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 when the list is empty. Can be a React Component Class, a render function, or a rendered element.
Rendered at the bottom of all the items. Can be a React Component Class, a render function, or a rendered element.
Rendered at the top of all the items. Can be a React Component Class, a render function, or a rendered element.
The default accessor functions assume this is an Array<{key: string}> but you can override getItem, getItemCount, and keyExtractor to handle any type of index-based data.
debug
will turn on extra logging and visual overlays to aid with debugging both usage and
implementation, but with a significant perf hit.
DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully unmounts react instances that are outside of the render window. You should only need to disable this for debugging purposes.
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.
A generic accessor for extracting an item from any sort of data blob.
Determines how many items are in the data blob.
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.
Instead of starting at the top with the first item, start at initialScrollIndex
. This
disables the "scroll to top" optimization that keeps the first initialNumToRender
items
always rendered and immediately renders the items starting at this initial index. Requires
getItemLayout
to be implemented.
Reverses the direction of scroll. Uses scale transforms of -1.
The maximum number of items to render in each incremental render batch. The more rendered at once, the better the fill rate, but responsiveness my suffer because rendering content may interfere with responding to button taps or other interactions.
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.
Note: may have bugs (missing content) in some circumstances - use at your own risk.
This may improve scroll performance for large lists.
Render a custom scroll component, e.g. with a differently styled RefreshControl
.
Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
screen. Similar fill rate/responsiveness tradeoff as maxToRenderPerBatch
.
Determines the maximum number of items rendered outside of the visible area, in units of
visible lengths. So if your list fills the screen, then windowSize={21}
(the default) will
render the visible screen area plus up to 10 screens above and 10 below the viewport. Reducing
this number will reduce memory consumption and may improve performance, but will increase the
chance that fast scrolling may reveal momentary blank areas of unrendered content.
Set this when offset is needed for the loading indicator to show correctly.
Scroll to a specific content pixel offset in the list.
Param offset
expects the offset to scroll to.
In case of horizontal
is true, the offset is the x-value,
in any other case the offset is the y-value.
Param animated
(true
by default) defines whether the list
should do an animation while scrolling.
Improve this page by sending a pull request!