我有一台FlatList。我在这个链接https://github.com/filipemerker/flatlist-performance-tips中使用了一些技巧
当用户滚动列表时,我正在更新新项目的数据。但在更新数据时,列表中的速度会变慢,还会出现一些But。我尽可能多地使用纯组件。我能为此做些什么呢?顺便说一下,我想在列表的末尾添加加载(活动指示器)。我该怎么做,你能举个例子或链接吗?
如果你帮忙,我会很高兴的,谢谢。
发布于 2019-01-22 12:26:47
React Native Pure组件以浅显的同情心实现shouldComponentUpdate。您可以通过在Component上实现自己的shouldComponentUpdate方法来严格检查要更新数据的道具。
shouldComponentUpdate(nextProps, nextState) {
return this.props.name !== nextProps.name;
}对于添加活动指示器,使用FlatList的ListFooterComponent属性。例如:
footerLoadingIndicator = () => {
return (
<View style={styles.footerContainer}>
<Progress.CircleSnail
size={30}
thickness={2.5}
direction={'clockwise'}
duration={400}
color={'#22a790'}
/>
</View>
);我使用了第三方指示器。您可以将其替换为AcitivityIndicator
https://stackoverflow.com/questions/54294922
复制相似问题