About the problem of reactjs warning with an endless loop

warning prompt:
Cannot update during an existing state transition (such as within render or another component"s constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to componentWillMount .

Click the query button to request the API to obtain the form data, and then setState renders it to the last page of Table,. After that, the browser console displays a bunch of warnings of endless loop prompts, until the memory overflow browser page crashes
has passed the solution and solved it according to their method. Finally, it will not work

.
fetchDatas = () => {
  ...
  this.setState({columns, dataSource: content});
}


<Button type="primary"  onClick={()=>{this.fetchDatas()}}></Button>

<Table loading={loading} onRow={this.onRow} rowKey={(record, index) => index} dataSource={dataSource} columns={columns} pagination={false} scroll={{x: 1000, y: 500}} />
Jan.11,2022

setState does not guarantee Synchronize, Synchronize, or Synchronize. Say the important thing three times, and the landlord can find the reason according to this


antd is really a bit of a pit. The browser console prompts that onRowClick, is not recommended. OnRow, is recommended. After I used onRow, there was a bunch of warnings of an endless loop until the browser crashed, and then it was normal to change onRow back to onRowClick

.
Warning: onRowClick is deprecated, please use onRow instead.
Menu