1

React native's FlatList Optimization Guide suggests the following:

Move out the renderItem function to the outside of render function, so it won't recreate itself each time render function called.

I have searched for information regarding this, and I have come across Does use of anonymous functions affect performance? The answers here show that deanonymizing the function would slightly improve performance, but the benefit is only relevant when applied in tight loops, not once per render. It is an insignificant improvement.

The official documentation makes use of anonymous functions in it's example and does not mention the matter of efficiency at all.

This leads me to believe there might be something I'm missing - could deanonymizing the function have other performance benefits specific to this situation? What are they?

Max Hay
  • 230
  • 2
  • 11
  • 1
    Probably the `FlatList` component needs to re-render every item when the `renderItem` prop changes its identity. It's the same reason why there's `useCallback` in React. – Bergi Aug 06 '21 at 16:41

0 Answers0