[英]React Native Flat List Data Change Render
I have a FlatList. 我有一个FlatList。 I applied tricks in this link https://github.com/filipemerker/flatlist-performance-tips
我在此链接中应用了技巧https://github.com/filipemerker/flatlist-performance-tips
When user scroll the list, I'm updating data for new items. 当用户滚动列表时,我正在更新新项目的数据。 But while updating data , there is a little slowless in the list and some bugs.
但是在更新数据时,列表中有一些缓慢的地方,还有一些错误。 I used pure component as much as possible.
我尽可能使用纯组分。 What can i do for that.
我该怎么办。 Bytheway i want to add loading(activict indicator) the end of the list.
顺便说一句,我想在列表的末尾添加loading(活动指示器)。 How can i do that, can you give a example or link for that.
我该怎么做,您能举个例子或链接吗。
If you help i will be happy thank you. 如果您有帮助,我将很高兴谢谢您。
React Native Pure component implement a shouldComponentUpdate with shallow compassion. React Native Pure组件以浅薄的同情实现了shouldComponentUpdate。 You can strictly check your props on which you want to update the data by implementing your own
shouldComponentUpdate
method on your Component
. 通过在
Component
上实现自己的shouldComponentUpdate
方法,可以严格检查要在其上更新数据的道具。
shouldComponentUpdate(nextProps, nextState) {
return this.props.name !== nextProps.name;
}
For adding Activity Indicator use ListFooterComponent
prop of FlatList. 要添加活动指示器,请使用
ListFooterComponent
的ListFooterComponent属性。 For example : 例如 :
footerLoadingIndicator = () => {
return (
<View style={styles.footerContainer}>
<Progress.CircleSnail
size={30}
thickness={2.5}
direction={'clockwise'}
duration={400}
color={'#22a790'}
/>
</View>
);
I have used a third party indicator. 我使用了第三方指标。 You can replace it with
AcitivityIndicator
您可以将其替换为
AcitivityIndicator
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.