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

如下图:

React ant table警告:Each child in a list should have a unique “key“ prop._第1张图片

原因

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

修复

添加这一行:

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

Table代码段:

<Table
    dataSource={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>
    }}
/>

你可能感兴趣的:(React,react.js,前端,前端框架)