问题
I'm passing a state object in 'autoGroupColumnDef' property of ag grid. On a switch, I need to update it's value.
Using setState is not helping in this case.
let temp = {...this.state.autoGroupColumnDef}
temp.field = "sport"
this.setState({ autoGroupColumnDef : temp })
<AgGridReact
columnDefs={this.state.columnDefs}
defaultColDef={this.state.defaultColDef}
animateRows={true}
enableRangeSelection={true}
rowData={this.state.rowData}
autoGroupColumnDef={this.state.autoGroupColumnDef}
onGridReady={this.onGridReady}
/>
The state get updated but table is not re-rendered.
I'm not sure if I'm setting the state the correct way since I'm new to reactjs.
来源:https://stackoverflow.com/questions/56982299/updating-autogroupcolumndef-object-doesnt-update-the-table