Updating 'autoGroupColumnDef' object doesn't update the table

萝らか妹 提交于 2020-01-25 12:45:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!