Skip to the page

RN performance · Write code

Optimizing a FlatList

The 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

  1. "What are windowSize, maxToRenderPerBatch, initialNumToRender and their trade-offs?"
  2. "When can you use getItemLayout?"
  3. "Why is an index key a bug here?"
  4. "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). renderItem defined outside JSX.
  • getItemLayout for fixed heights. Tune initialNumToRender to fill one screen.
  • windowSize defaults to 21 viewports: lower it to save memory at the risk of blank areas. maxToRenderPerBatch defaults to 10 (fill rate vs responsiveness). updateCellsBatchingPeriod defaults to 50 ms.
  • removeClippedSubviews defaults 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 voice

Practise 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.

Start your free interview