Optimizing React Native Lists: FlatList, Memoization, and Rendering
A list of 20 items might feel fast in development and still stutter when it grows to hundreds of items with images, badges, and interactive controls. FlatList already virtualizes content, but row complexity, unnecessary updates, and image work can still cause dropped frames.
The right approach is to measure first, simplify the work in each row, and only then tune virtualization settings.
Start with a small, predictable list
This TypeScript example uses stable IDs, a memoized row component, and a stable render function:
import React, { memo, useCallback } from 'react';
import { FlatList, Pressable, Text, View } from 'react-native';
type Product = {
id: string;
title: string;
price: number;
};
type Props = {
products: Product[];
onSelect: (id: string) => void;
};
const ProductRow = memo(function ProductRow({
product,
onPress,
}: {
product: Product;
onPress: (id: string) => void;
}) {
return (
<Pressable onPress={() => onPress(product.id)}>
<View style={{ padding: 16 }}>
<Text>{product.title}</Text>
<Text>${product.price.toFixed(2)}</Text>
</View>
</Pressable>
);
});
export function ProductList({ products, onSelect }: Props) {
const renderItem = useCallback(
({ item }: { item: Product }) => (
<ProductRow product={item} onPress={onSelect} />
),
[onSelect]
);
return (
<FlatList
data={products}
keyExtractor={(item) => item.id}
renderItem={renderItem}
/>
);
}
React.memo skips a row render when its props compare equal. This helps when product objects and onSelect references remain stable; it does not eliminate updates when you rebuild every product object on every parent render. The inline onPress function inside each row is usually fine—optimize only if profiling identifies it as a problem.
Keep keys stable
Use a unique ID from your data as keyExtractor. Array indices are risky for lists where items are inserted, removed, sorted, or reordered: React may associate state with the wrong row.
<FlatList
data={products}
renderItem={renderItem}
keyExtractor={(item) => item.id}
/>
Avoid generating random keys during render. Changing keys tells React to treat items as new components.
Make rows cheaper to render
Start with the actual cost of a row:
- Reduce deeply nested layouts when the UI can be simpler.
- Resize and cache images appropriately. Large decoded images can hurt memory and scrolling.
- Keep expensive formatting or derived data outside frequently rendered rows when possible.
- Avoid passing new object props to memoized rows unless needed.
- If selection state changes, pass the minimal relevant state to each row rather than a large changing object.
useMemo and useCallback are tools for stabilizing references or expensive computations—not automatic performance improvements. Add them where there is a measurable reason.
Use getItemLayout when item sizes are fixed
When every row has a predictable height, provide its layout so FlatList can avoid measuring it asynchronously:
const ROW_HEIGHT = 64;
<FlatList
data={products}
renderItem={renderItem}
keyExtractor={(item) => item.id}
getItemLayout={(_, index) => ({
length: ROW_HEIGHT,
offset: ROW_HEIGHT * index,
index,
})}
/>
The earlier ProductRow does not enforce a fixed height, so do not apply this example unchanged to it. Only use this when the row's actual total height—including separators when applicable—is consistent. Incorrect offsets can break scrollToIndex and produce awkward scroll behavior.
Tune virtualization carefully
FlatList offers several knobs, each with trade-offs:
| Prop | Purpose | Trade-off |
|---|---|---|
initialNumToRender | Rows rendered initially | More rows increase initial work |
maxToRenderPerBatch | Rows rendered in each incremental batch | Large batches may block responsiveness |
updateCellsBatchingPeriod | Time between batches | Longer periods may expose blank areas |
windowSize | Size of rendered window, in viewport units | Larger windows use more memory |
removeClippedSubviews | Detach offscreen native views where supported | Can cause missing-content issues in some layouts |
There is no single best configuration for every phone, row size, and scroll pattern. Test one change at a time and compare the result on low-end Android hardware as well as iOS.
Measure in a release-like build
Development mode adds work that users do not see. Reproduce slow scrolling in a release or profiling build and watch for:
- JS-side work: expensive render calculations, state updates, or list transforms.
- UI-side work: complex layout, image decode, and native view updates.
- Network or cache behavior: remote images that load or re-render while scrolling.
Use React Native DevTools and platform profiling tools where appropriate. If a row is rendering more often than expected, inspect which props change before adding more memoization.
When FlatList is not enough
If you're rendering a very large feed with heterogeneous item sizes, test a specialized list implementation against your actual workload. Switching libraries can help, but it will not fix unstable keys, heavy image work, or unnecessary app state changes.
Takeaway: stable identities, simple rows, and measured improvements usually matter more than a long list of magic props.