昨天在Ant desgin pro開(kāi)發(fā)新建一個(gè)列表頁(yè)面遇到警告錯(cuò)誤: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都差異化設(shè)置完了速兔,還是會(huì)出現(xiàn),讓人頭疼的很微谓。后來(lái)去對(duì)比了其他頁(yè)面時(shí),發(fā)現(xiàn)少了rowKey
設(shè)置输钩,原來(lái):
<ProTable
key='table'
search={{
labelWidth: 'auto',
}}
...
/>
后來(lái)改為這樣就好了(前提是你的列表每項(xiàng)數(shù)據(jù)里必須有id
字段):
<ProTable
rowKey="id"
key='table'
search={{
labelWidth: 'auto',
}}
...
/>