React-Native FlatList performance problems with large list

前端 未结 2 1843
时光说笑
时光说笑 2020-12-31 09:28

My code gets Json data to an array lists the data using a FlatList. It looks like a phonebook photo and text in a row.

Here is My code:

         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-31 10:01

    Here are some improvements you can do to optimize your flatlist:

    1. Pagination
      • You can paginate your data in your backend and refetch it when your scroll gets closer to the end. onEndReached and onEndReachedThreshold can help you.
    2. Update your React Native version to 49 or latest
      • Fiber 16 has amazing performance improvement which makes everything runs faster and smoother
    3. Use PureComponent for render item
      • PureComponent improves the rendering and memory usage of your component, creating render items as pure gives you a better performance experience
    4. Define getItemLayout prop
      • It improves item rendering since React will previously know its layout definition

    Hope it helps

提交回复
热议问题