RN performance · Write code
Optimizing a FlatList
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
"How can you optimize a FlatList?" Follow it with this code review:
<FlatList
data={orders}
renderItem={({ item }) => <OrderRow order={item} onPress={() => open(item.id)} />}
keyExtractor={(item, index) => String(index)}
/>
Then
Follow-ups the interviewer asks next
- "What are
windowSize,maxToRenderPerBatch,initialNumToRenderand their trade-offs?" - "When can you use
getItemLayout?" - "Why is an index key a bug here?"
- "When would you move to FlashList or Legend List?"
The answer
What a strong answer covers
- Stable
keyExtractor(id, not index). A memoized row with stable callbacks (useCallback, pass an id not a closure).renderItemdefined outside JSX. getItemLayoutfor fixed heights. TuneinitialNumToRenderto fill one screen.windowSizedefaults to 21 viewports: lower it to save memory at the risk of blank areas.maxToRenderPerBatchdefaults to 10 (fill rate vs responsiveness).updateCellsBatchingPerioddefaults to 50 ms.removeClippedSubviewsdefaults to on for Android and can cause missing content on iOS.- Light rows with thumbnails and cached images.
The red pen
Common traps
Avoid:"set windowSize to 100". Wrapping a FlatList in a ScrollView. Inline arrow props defeating memo.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.