Lists: thousands of rows without jank · mid
Tuning FlatList: getItemLayout, batching and light rows
A FlatList is fast when its rows are cheap and stable (memoized row, stable callbacks, stable keys, small cached images) and when it can skip measuring rows (getItemLayout for fixed heights), with window and batch props changed only after measuring.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Make the row a React.memo component and pass stable props: an id and a stable callback (useCallback), not a new arrow function per row. React Compiler can do much of this for you.
- getItemLayout(data, index) => ({ length, offset, index }) for fixed-height rows lets FlatList skip measuring and makes scrollToIndex exact. Include the separator height in the offset.
- Defaults: initialNumToRender 10, maxToRenderPerBatch 10, updateCellsBatchingPeriod 50 ms, windowSize 21, removeClippedSubviews true on Android only.
- Lower windowSize saves memory but risks blank areas. Higher maxToRenderPerBatch fills faster but blocks taps for longer.
- removeClippedSubviews detaches off-screen views but does not free them, and can make content disappear on iOS.
- Keep rows light: few nested Views, thumbnails instead of full images, no heavy work during render, no console.log.
- The React Native docs now suggest FlashList or Legend List for big or complex lists.
The red pen
Common traps: mistake → fix
Mistake: "Set windowSize to 100 so nothing is ever blank"
Fix: memory grows and the JS thread does much more work.
Mistake: "getItemLayout works for every list"
Fix: only when you can compute each row's height and offset without measuring.
Mistake: "React.memo on the row is enough"
Fix: onPress={() => open(item.id)} creates a new function every render and breaks memo.
Easy to hard
Questions interviewers ask, easy to hard
- How can you optimize a FlatList? (code review)
- When can you use getItemLayout? Write it for 72 dp rows with a 1 dp separator.
- What are the trade-offs of windowSize, maxToRenderPerBatch and initialNumToRender?
- When would you switch to FlashList or Legend List?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.