React-virtualized: Changing grid's columnWidth dynamically doesn't re-render

Created on 12 Sep 2017  路  2Comments  路  Source: bvaughn/react-virtualized

Not sure if this is a bug or just something I wouldn't expect.
I use Grid's prop columnWidth like so:

getColumnWidth = (e:{index:number})=>{
        if (this.props.something==true && e.index==0){
            return 20;
        }else{
            return 100;
        }
    };
<Grid
  cellRenderer={this.cellRenderer(this.props.something)}
  columnCount={this.getColumnsLength()}
  columnWidth={this.getColumnWidth}
  height={300}
  rowCount={this.props.value.length}
  rowHeight={70}
  width={800}
/>

when changing this.props.something to true dynamically (after it has already renderer with
getColumnWidth actually runs like it should, however, further cellRenderer calls are still called with the incorrect style.
new rows added later are styled correctly. After scrolling everything re-renders and its ok.

Anyone familiar with this issue?

Most helpful comment

Sounds like you're not calling recomputeGridSize between renders. You'll need to call this method if previous sizes are no longer valid.

All 2 comments

Sounds like you're not calling recomputeGridSize between renders. You'll need to call this method if previous sizes are no longer valid.

Thanks! didn't see that one.

Was this page helpful?
0 / 5 - 0 ratings