reactjs - 对于反应虚拟化的砌体,处理删除项目的推荐方法是什么?
问题描述
https://codesandbox.io/s/l79vn4rowq
删除项目时,我没有重新初始化 cellMeasurerCache,因为我已经有了每个项目的尺寸。invalidateCellSizeAfterRender
通过这样做,不会设置填充位置缓存的上限和下限,因为如果缓存中已经存在维度,则 CellMeasurer 不会调用。
//hack to set a range for populating position cache
masonryInstance.invalidateCellSizeAfterRender({ rowIndex: 0 });
masonryInstance.invalidateCellSizeAfterRender({
rowIndex: batchSize - 1
});
//populate position cache
masonryInstance.recomputeCellPositions();
我不得不使用 hack 方法invalidateCellSizeAfterRender
来设置填充位置缓存的上限和下限。有一个更好的方法吗?
解决方案
推荐阅读
- c# - 规范化 HtmlAgilityPack 中的空间
- python - 如何从关联表中查询属性(SQLalchemy)
- apache-spark - 为多个租户触发具有条件过滤逻辑的作业
- c# - HttpWebRequest 获取“底层连接已关闭”
- python - 多处理,Python3,Windows:TypeError:无法腌制 _thread.lock 对象
- c - 将整数和字符串转换为十六进制字符串,并在 C 中以正确的字节序将它们放置在其他十六进制字符串之间
- mysql - 从 SELECT 语句返回的行更新值
- java - 如何限制用户选择 RecyclerView 列表中的 3 个选项
- sql-server-2000 - SQL Server 2000 中一列对应列的最大值
- push-notification - 适用于 iOS 和 Android 应用程序的 EWS 新电子邮件推送通知