javascript - React Native Flat List 数据更改渲染
问题描述
我有一个平面列表。我在此链接中应用了技巧https://github.com/filipemerker/flatlist-performance-tips
当用户滚动列表时,我正在更新新项目的数据。但是在更新数据的时候,列表有点慢,还有一些bug。我尽可能使用纯组件。我能为此做些什么。顺便说一句,我想在列表末尾添加加载(活动指示器)。我该怎么做,你能给一个例子或链接。
如果你帮助我会很高兴谢谢你。
解决方案
React Native 纯组件实现了一个带有浅同情的 shouldComponentUpdate。您可以通过shouldComponentUpdate
在Component
.
shouldComponentUpdate(nextProps, nextState) {
return this.props.name !== nextProps.name;
}
要添加活动指示器,请使用ListFooterComponent
FlatList 的道具。例如 :
footerLoadingIndicator = () => {
return (
<View style={styles.footerContainer}>
<Progress.CircleSnail
size={30}
thickness={2.5}
direction={'clockwise'}
duration={400}
color={'#22a790'}
/>
</View>
);
我使用了第三方指标。您可以将其替换为AcitivityIndicator
推荐阅读
- html - 正文背景颜色仅应用于元素
- java - 在 Controller 中使用 @Autowired 和 @Qualifier 更改服务的数据源
- c# - 将项目从 2005 年的可视化 Web 开发人员转移到 2015 年的可视化 Web 开发人员
- javascript - 如何在 Django 中正确使用 webpack 等前端技术?
- javascript - 使用 .Net Framework 调用角度函数
- arrays - 查找数组的名称
- docker - 来自多个代理存储库的 Nexus 优先级
- sql - 有没有办法可以减去两列?
- php - 检查正确密码后插入php代码段
- java - 在作业提交期间访问 Hadoop 计数器