Ant Design's table component reports an error Warning: Each child in a list should have a unique “key” prop.

This error occurred when using the table component of Ant Design

The reason is that each column of data in the table must use the key value of the data as a unique identifier,
and the data I received does not have the attribute of key

 solution:

  • 1. Add a key value to each item of data, which is more troublesome

  • 2. Use rowKey on the table component to specify the value of the table row key. Since the data I received has an attribute of id, I can directly assign the id to rowKey.
<Table bordered 
dataSource={this.state.list} 
columns={this.state.columns} 
pagination={false} 
rowKey={"id"}>

Guess you like

Origin blog.csdn.net/q1277517096/article/details/129188809