본문 바로가기
오류 해결

antd table 사용할 때 Warning: Each child in a list should have a unique "key" prop. Check the render method of `Body`. 에러

by 질서정연_ 2023. 5. 24.

https://github.com/ant-design/ant-design/issues/7623

 

Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key. · Issue #7623 · ant-design/ant-

I'm trying to figure out how can I get unique keys for each record. So far, my code looks like this: let lastIndex = 0 const updateIndex = () => { lastIndex++ return lastIndex } ... constructor() {...

github.com

 

antd table 에 넣어 줄 data source 객체 값들에 key 를 넣어줘야된다고 한다 .!!!!!!!

 

 

 const sendData = [
        {
            'key':'sendData1',
            'name': '저쩌고',
            'value': '저쩌고'
        },
        {
            'key':'sendData2',
            'name': '어쩌고',
            'value': '저쩌고'
        }
    ];

 

이렇게 해 주고 dataSource에 넣어주면 된다. 

댓글