昨天在Ant desgin pro开发新建一个列表页面遇到警告错误:Warning: Each child in a list should have a unique "key" prop. Check the render method of Body
. See https://reactjs.org/link/warning-keys for more information.
找了大半天,各种render的key都差异化设置完了,还是会出现,让人头疼的很。后来去对比了其他页面时,发现少了rowKey
设置,原来:
<ProTable
key='table'
search={{
labelWidth: 'auto',
}}
...
/>
后来改为这样就好了(前提是你的列表每项数据里必须有id
字段):
<ProTable
rowKey="id"
key='table'
search={{
labelWidth: 'auto',
}}
...
/>