0

Every next search query starts with previous page height and index count. What can I do to update the index count in cellRenderer and the height of the page on a new search query? Next code help to avoid errors, but doesn't solve the problem:

cellRenderer = ({index, key, parent, style}) => {
    const image = this.props.images.items[index];

    if (!image) {
        console.log('!image (empty image with index: ', index, 'style', style);
        return;
    }

Code: pastebin.com/FB7kzDb4

1 Answers1

1

tl;dr You can fix your demo by doing the following:

// Clear any JIT measurements
cellMeasurerCache.clearAll();

// Reset the position cache
cellPositioner.reset({
  columnCount: this.columnCount,
  columnWidth: this.columnWidth,
  spacer: this.spacer,
});

// Let Masonry know it needs to relayout
this.masonry.clearCellPositions();

Here is an example of me doing the same on the RV demo page. You can see it running here by clicking the "Reset List" button.

bvaughn
  • 13,300
  • 45
  • 46
  • Brian, thank you for quick answer and your contribution to popularization React.js. A lot of people really appreciate it. Keep it up! – Max Mabius Nov 29 '17 at 08:03