react-seatmap icon indicating copy to clipboard operation
react-seatmap copied to clipboard

Rows are not updating on props change from parent

Open anarayn opened this issue 7 years ago • 1 comments

First of all thanks for sharing such a nice library. It perfectly fits my use case.
I am facing a problem and unable to find a way out so raising this issue for help.

I am rendering the Seatmap component inside my component. My component accepts number of rows and columns from user as input and based on that it generates rows and pass to Seatmap. here is my function used for generating rows.

const computeRows = (nRow, nCol, disableCols, blanks) => {
    let totalSeats = 1;
    const rowMap = [];
    for (let i = 0; i < nRow; i++) {
      const rowSeats = [];
      let blankSeats = [];
      if (blanks) {
        blankSeats = blanks[i + 1] ? blanks[i + 1] : [];
      }
      for (let j = 0; j < nCol; j++) {
        if (disableCols.includes(j + 1) || blankSeats.includes(j + 1)) {
          rowSeats.push(null);
        } else {
          rowSeats.push({ number: totalSeats });
          totalSeats += 1;
        }
      }
      rowMap.push(rowSeats);
    }
    return rowMap;
  };

When the compoenet render the first time then it displays the layout perfectly, but when value of rows and columns are changed by user it doesn't reflect in layout. I tried debugging and noticed shouldComponentUpdate method is called with updated props in Seatmap but still layout is not updating based on my new rows. Is it something related to Immutable Js used in Seatmap component?

Thanks in advance!

anarayn avatar Jun 14 '18 06:06 anarayn

@anarayn Little bit late for this, but do you already solved this issue? because I'm also need a solution for this.

rolies106 avatar Jul 22 '23 00:07 rolies106