https://codesandbox.io/s/l79vn4rowq
When deleting items, I am not reinitializing the cellMeasurerCache, as I already have the dimensions of each item. By doing so, the upper and lower bound for populating position cache is not set as the CellMeasurer doesn't invoke invalidateCellSizeAfterRender
if the dimensions are already present in the cache.
//hack to set a range for populating position cache
masonryInstance.invalidateCellSizeAfterRender({ rowIndex: 0 });
masonryInstance.invalidateCellSizeAfterRender({
rowIndex: batchSize - 1
});
//populate position cache
masonryInstance.recomputeCellPositions();
I had to use the hack method invalidateCellSizeAfterRender
for setting the upper and lower bounds for populating position cache. Is there a better way to do this?