This may be an anti pattern, but I'm using fixed-data-table to display tables with changing columns. The resize function resizes the width of each column based on a state change. However, I need to build the state or columns from props received. I can't update the state from the render function. Is there a better way to go about this? My best solution so far was to generate the state width to 100, but this is temporary.
constructor(props) {
super(props);var columnWidths ={
recordid: 40,
};
for(var i=0; i<100;i++) {
columnWidths[i]=200
}
this.state = {
columnWidths
};
this._onColumnResizeEndCallback = this._onColumnResizeEndCallback.bind(this);
}
_onColumnResizeEndCallback(newColumnWidth, columnKey) {
this.setState(({ columnWidths }) => ({
columnWidths: {
...columnWidths,
[columnKey]: newColumnWidth,
}
}));
console.log(newColumnWidth + " " + columnKey)
}