React ant table警告:Each child in a list should have a unique “key“ prop.

如下图:

在这里插入图片描述

原因

React Ant table表格每一行都需要一个唯一标识来确保不重复,如果不加该属性,就会出现这个警告。

修复

添加这一行:

rowKey={(record) => record.id}    # id为行id

Table代码段:

<TabledataSource={tableData}columns={this.getSchemeData()}rowKey={(record) => record.id}size={'small'}loading={{spinning: isLoading, indicator: <span style={{position: 'absolute',top: '50%',left: '50%',margin: '-24px',}}><Spinner size={"large"}/></span>}}
/>