请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

哇偶 报错了 Each child in a list should have a unique "key" prop

index.js:1 Warning: Each child in a list should have a unique “key” prop.

Check the render method of App. See https://reactjs.org/link/warning-keys for more information.
at Robot (http://localhost:3000/static/js/main.chunk.js:290:3)
at App
图片描述

正在回答

1回答

阿莱克斯刘 2021-04-06 02:25:52

这个报错解决很简单,请在for循环的组件中加上key就好了,如图所示

function App() {
  return (
    <ul>
      {robots.map((r, index) => (
         <Robot key={index} id={r.id} email={r.email} name={r.name} />
      ))}
    </ul>
  );
}

https://img1.sycdn.imooc.com//szimg/606b55f6097434b918000570.jpg

0 回复 有任何疑惑可以回复我~
  • 提问者 i杨永安 #1
    非常感谢!
    回复 有任何疑惑可以回复我~ 2021-04-06 12:08:21
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信