Explain it simply
Lists with FlatList, in plain language
FlatList mainly works with three props: data (the array), renderItem (how to display each item), and keyExtractor (a unique key for each item). ScrollView + .map() renders every item upfront, including ones not yet visible on screen, which can cause memory/performance problems with hundreds of items — FlatList instead uses virtualization (rendering only items near the screen and recycling the rest), keeping performance solid for lists with hundreds of items.
Problem → Why → Solution
The problem — why this concept matters
Skipping keyExtractor and relying on the array index as the default key — this can cause bugs when the list changes
A common mistake
Continuing to use ScrollView + .map() for lists with hundreds of items (hurts performance)
Core concept — understand how it works
Treat Lists with FlatList as a native UI contract covering Yoga constraints, pixel density, font scaling, safe areas, the keyboard, touch targets, the accessibility tree, and iOS/Android differences—not merely screen styling syntax.
- JavaScript state
- native component and layout
- Android or iOS UI
Explain the React and native-platform behavior of Lists with FlatList
Core syntax or pattern
import { FlatList, View, Text, StyleSheet } from 'react-native';
const products = [
{ id: '1', name: 'T-Shirt', price: '15000 MMK' },
{ id: '2', name: 'Sneakers', price: '85000 MMK' },
{ id: '3', name: 'Backpack', price: '45000 MMK' },
];
export default function ProductList() {
return (
<FlatList
data={products}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={styles.card}>
<Text style={styles.name}>{item.name}</Text>
<Text>{item.price}</Text>
</View>
)}
/>
);
}
const styles = StyleSheet.create({
card: { padding: 16, borderBottomWidth: 1, borderColor: '#eee' },
name: { fontWeight: '600', fontSize: 16 },
});Treat Lists with FlatList as a native UI contract covering Yoga constraints, pixel density, font scaling, safe areas, the keyboard, touch targets, the accessibility tree, and iOS/Android differences—not merely screen styling syntax.
Read the code step by step
- JavaScript state
import { FlatList, View, Text, StyleSheet } from 'rea...FlatList mainly works with three props: data (the array), renderItem (how to display each item), and keyExtractor (a unique key for each item). ScrollView + .map() renders every item upfront, including ones not yet visible on screen, which can cause memory/performance problems with hundreds of items — FlatList instead uses virtualization (rendering only items near the screen and recycling the rest), keeping performance solid for lists with hundreds of items.
- native component and layout
<View style={styles.card}>Treat Lists with FlatList as a native UI contract covering Yoga constraints, pixel density, font scaling, safe areas, the keyboard, touch targets, the accessibility tree, and iOS/Android differences—not merely screen styling syntax.
- Android or iOS UI
});Test an original Lists with FlatList example on Android and iOS with small and large screens, font scaling, dark mode, keyboard and screen reader use, slow/offline networking, denied permissions, and background/foreground transitions. Use DevTools, tests, and a release build where relevant.
- JavaScript state
- native component and layout
- Android or iOS UI
Success
Explain the React and native-platform behavior of Lists with FlatList
Failure
Skipping keyExtractor and relying on the array index as the default key — this can cause bugs when the list changes
Let's think about this for a moment
FlatList mainly works with three props: data (the array), renderItem (how to display each item), and keyExtractor (a unique key for each item). ScrollView + .map() renders every item upfront, including ones not yet visible on screen, which can cause memory/performance problems with hundreds of items — FlatList instead uses virtualization (rendering only items near the screen and recycling the rest), keeping performance solid for lists with hundreds of items.
Let's connect this to a real scenario
Chat app message lists, e-commerce product lists, social media feeds — FlatList is the standard choice for any list with lots of items like these. Inside renderItem you return a card component for each item, and for keyExtractor you pass item._id or item.id converted to a string — an incorrect key can hurt React's reconciliation performance.
Code Example
import { FlatList, View, Text, StyleSheet } from 'react-native';
const products = [
{ id: '1', name: 'T-Shirt', price: '15000 MMK' },
{ id: '2', name: 'Sneakers', price: '85000 MMK' },
{ id: '3', name: 'Backpack', price: '45000 MMK' },
];
export default function ProductList() {
return (
<FlatList
data={products}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={styles.card}>
<Text style={styles.name}>{item.name}</Text>
<Text>{item.price}</Text>
</View>
)}
/>
);
}
const styles = StyleSheet.create({
card: { padding: 16, borderBottomWidth: 1, borderColor: '#eee' },
name: { fontWeight: '600', fontSize: 16 },
});You'll be able to render a scrollable product list with FlatList.5-Minute Try-It
Create your own data array (e.g. a list of favorite movies) and try rendering it with FlatList.
A Quick Heads-Up
Don't nest FlatList inside a ScrollView (you'll get a 'VirtualizedList nested inside ScrollView' warning) — use a View for the outer container, ScrollView isn't needed.
Real-world usage
How to apply it in a real project
Test an original Lists with FlatList example on Android and iOS with small and large screens, font scaling, dark mode, keyboard and screen reader use, slow/offline networking, denied permissions, and background/foreground transitions. Use DevTools, tests, and a release build where relevant.
Mini challenge
Build it yourself
Test an original Lists with FlatList example on Android and iOS with small and large screens, font scaling, dark mode, keyboard and screen reader use, slow/offline networking, denied permissions, and background/foreground transitions. Use DevTools, tests, and a release build where relevant.
- Rebuild the example without copying it
- Test a normal input and an edge case
- Predict the compiler or output result before running it
import { FlatList, View, Text, StyleSheet } from 'react-native';
const products = [
{ id: '1', name: 'T-Shirt', price: '15000 MMK' },
{ id: '2', name: 'Sneakers', price: '85000 MMK' },
{ id: '3', name: 'Backpack', price: '45000 MMK' },
];
export default function ProductList() {
return (
<FlatList
data={products}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={styles.card}>
<Text style={styles.name}>{item.name}</Text>
<Text>{item.price}</Text>
</View>
)}
/>
);
}
const styles = StyleSheet.create({
card: { padding: 16, borderBottomWidth: 1, borderColor: '#eee' },
name: { fontWeight: '600', fontSize: 16 },
});Expected: Explain the React and native-platform behavior of Lists with FlatList
Show hint
Test an original Lists with FlatList example on Android and iOS with small and large screens, font scaling, dark mode, keyboard and screen reader use, slow/offline networking, denied permissions, and background/foreground transitions. Use DevTools, tests, and a release build where relevant.
Quick quiz 1 / 3
Quick quiz 2 / 3
Quick quiz 3 / 3
What to remember
- JavaScript state → native component and layout → Android or iOS UI
- Treat Lists with FlatList as a native UI contract covering Yoga constraints, pixel density, font scaling, safe areas, the keyboard, touch targets, the accessibility tree, and iOS/Android differences—not merely screen styling syntax.
- Skipping keyExtractor and relying on the array index as the default key — this can cause bugs when the list changes
- Test an original Lists with FlatList example on Android and iOS with small and large screens, font scaling, dark mode, keyboard and screen reader use, slow/offline networking, denied permissions, and background/foreground transitions. Use DevTools, tests, and a release build where relevant.
React Native Documentation — React Native