I am using the Grid component of react-virtualized, which expects column count and column width as required props. Right now, I am explicitly calculating the screen widths on resizing, and am calculation column width and column count.
My code is as follows:
let gridsNum = this.getColumnCount(this.state.width);
let colWidth = this.state.width / gridsNum;
<Grid
cellRenderer={this.cellRenderer}
columnCount={gridsNum}
columnWidth={colWidth}
height={window.innerHeight}
rowCount={this.state.messages.length}
rowHeight={310}
onScroll={this.onScroll}
width={window.innerWidth}
className="jobs-gridview"
/>
getColumnCount(width){
if(width > 1350){
return 4;
}else if(width > 1000){
return 3;
}else if(width > 650){
return 2;
}else{
return 1;
}
}
I also went through the earlier plunkr example regarding a similar issue: http://plnkr.co/edit/zjCwNeRZ7XtmFp1PDBsc?p=preview.
I apologize for the poor quality of code. Is there anything better I can do to improve Grids for responsiveness?
Thanks.