react使用ant-design的table出现这个报错怎么解决呢?

使用table组件的时候报这个错误Warning: Each child in a list should have a unique "key" prop.Check the render method of Cell2.应该怎么解决,这个错误是与columns={columns}相关还是与dataSource={data}相关,我在table上面绑定了rowKey='id'还是不能解决image.png

还有就是他说的是cell2是不是与columns里面的第二项有关,以下是columns的第二项

{
      title: '题型类型', //题型类型
      dataIndex: record=>record._genreName?record._genreName:record.tqTypeName,
      key: data.some((item) => '_genreName' in item) ? '_genreName' : 'tqTypeName',
        render: (text, record) => {
        let options = optionData;
            const currentIndex = options.findIndex((option) => option.genreName === text||option.tqCType === text);
        if (currentIndex !== -1) {
            options = options.slice(currentIndex);
        }
        return (
        <Select
            key={record.id}
            value={record._genreName?record._genreName:record.tqTypeName}
            onChange={(value) => handleInputChange('_genreName', value, record)}
        >
            {options.map((option,index) => (
            <Option key={index} value={option.genreName||option.tqCType}>
                {option.genreName||option.tqCType}
            </Option>
            ))}
        </Select>
        );
      },
      width: '15%'
    },
阅读 2.6k
1 个回答
<Option key={option.genreName || option.tqCType} value={option.genreName || option.tqCType}>
    {option.genreName || option.tqCType}
</Option>

key注意要是唯一的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题