map() with ScrollView, these components only render items currently visible on screen.
FlatList vs ScrollView
FlatList
Lazy-loads items as you scroll. Best for large datasets. Only renders visible items.
ScrollView
Renders all children at once. Good for small, static lists. Simple but not performant for large lists.
Basic FlatList
TheFlatList component requires two props: data and renderItem.
FlatList Example
FlatList Props
Essential Props
Array
required
The array of items to render
Function
required
Function that returns JSX for each item. Receives
{item, index, separators} as argument.Function
Function that returns a unique key for each item. Default uses
item.key or falls back to index.From React Native Source
FromLibraries/Lists/FlatList.js:
FlatList.js (source)
Real-World Example
A contact list with touchable items:Contact List
Performance Optimization
getItemLayout
If your items have fixed height, providegetItemLayout for better performance:
From the React Native source: “getItemLayout is an optional optimization that lets us skip measurement of dynamic content if you know the height of items a priori.”
initialNumToRender
Control how many items render initially:Headers, Footers, and Empty States
Pull to Refresh
SectionList
For lists with section headers, useSectionList:
SectionList Example
SectionList from Source
FromLibraries/Lists/SectionList.js:
SectionList.js (source)
Horizontal Lists
Multiple Columns
Infinite Scroll
Best Practices
Always provide keyExtractor
Always provide keyExtractor
Keys help React identify which items have changed, are added, or removed. Never use array index as key for dynamic lists.
Use PureComponent or React.memo for list items
Use PureComponent or React.memo for list items
Prevent unnecessary re-renders of list items when parent updates.
Provide getItemLayout for fixed-height items
Provide getItemLayout for fixed-height items
This skips measurement and improves scroll performance significantly.
Use removeClippedSubviews on Android
Use removeClippedSubviews on Android
Unmount components that are off screen to reduce memory usage.
Optimize images in lists
Optimize images in lists
Use appropriate image sizes and consider using FastImage for better performance.
Next Steps
Networking
Learn to fetch data for your lists from APIs
Platform-Specific Code
Handle list behavior differences between iOS and Android