ReactNative Flatlist - Flatlist 项目的优化性能 [英] ReactNative Flatlist - Optimization performance of Flatlist items
问题描述
我的列表有图片和文字说明.
My list has both an image and an text description.
我想找到一种方法来提高列表的性能并删除从缓存列表中加载的额外图像并使列表不重.
I want to find a way to increase performance of list and remove extra images loaded from the cache list and make the list not heavy.
推荐答案
有一种叫做 PureComponent 在本机反应中.如果您将 FlatList
项创建为 PureComponent
,您会看到很多改进.在数据更改之前,它不会重新渲染项目.
There is something called PureComponent in react native. If you create your FlatList
item as PureComponent
, you can see lot of improvement. It will not rerender items untill data has been changed.
像这样:
class MyListItem extends React.PureComponent {
}
即使是 Nino9612 建议的库 react-native-optimized-flatlist 也使用相同的概念,你可以看到他们的代码 FlatListItem
Even the library suggested by Nino9612 react-native-optimized-flatlist is also using the same concept, as you can see code of their FlatListItem
这篇关于ReactNative Flatlist - Flatlist 项目的优化性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!