FlatList: Performant Virtualized Lists in React Native
FlatList is a "window" over your data, only rendering visible items to save memory and keep scrolling smooth. It's ideal for long lists like feeds or contacts. The main footgun: if items don't update, you forgot to pass changing state to the extraData prop.
Why it exists
Rendering a list with thousands of items by mapping over an array would create thousands of component instances at once, consuming huge amounts of memory and likely crashing a mobile app. Mobile devices have limited resources, so a more efficient strategy is needed for long lists.
The mental model
Think of FlatList as a virtualized list. It maintains a small "render window" of items that are currently on-screen or just off-screen. As you scroll, it unmounts components that scroll out of view and mounts new ones scrolling into view. This keeps memory usage low and constant, regardless of the list's total length.
How it works
FlatList requires two main props: data, an array of your list items, and renderItem, a function that tells the list how to render a single item from the data. To uniquely identify items for efficient updates, it uses a function you provide to the keyExtractor prop. Because it's a PureComponent for performance, it only re-renders when its props receive new references. If an item's rendering depends on state outside the data prop (like a selected item ID), you must pass this state via the extraData prop to tell FlatList that it needs to re-render its items.
When to use it
Use FlatList for any simple, long, or infinitely scrolling list of items that have a similar structure. Examples include a social media feed, a list of emails, a product gallery, or a contact list. Its built-in support for features like pull-to-refresh, separators, and multiple columns (numColumns) makes it very versatile.
When not to use it
If your list needs to be broken into logical sections with headers (like a contact list grouped by letter), use the <SectionList> component instead. For very short, static lists where performance is not a concern, a simple .map() inside a <ScrollView> might be simpler, though FlatList is generally the safer default.
One canonical example
To render a simple list of users, you provide an array of user objects to the data prop and a function to renderItem. The renderItem function receives an object containing the item (e.g., {id: '1', name: 'Alice'}) and returns a component displaying the user's name. You must also provide a keyExtractor function, like item => item.id, to give each rendered element a stable identity for React's reconciliation process.
Interview question
What is the primary mechanism FlatList uses to ensure smooth performance with long lists on mobile devices?
- a.It compresses the data prop and individual item components to reduce memory usage.
- b.It automatically caches the results of renderItem calls to avoid re-executing them for identical data.
- c.It renders all list items immediately but off-screen, then quickly displays them as needed.
- d.It maintains a small "render window" of items, mounting and unmounting components as the user scrolls.Correct
Why? this is the answer
FlatList's core performance optimization is virtualization, which means it only renders a limited "window" of items that are currently visible or near the viewport. Option C is incorrect because rendering all items, even off-screen, would still consume excessive memory, which FlatList aims to prevent.
Just read this? Test yourself on what you have been reading.
Read the original → reactnative.dev
- #react native
- #mobile
- #ui component
- #performance
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on react native — each one lists the topics its interview covers.
See open roles