哇偶 报错了 Each child in a list should have a unique "key" prop
来源:3-4 【组件化】初识React函数式组件

i杨永安
2021-03-31
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回答
-
这个报错解决很简单,请在for循环的组件中加上key就好了,如图所示
function App() { return ( <ul> {robots.map((r, index) => ( <Robot key={index} id={r.id} email={r.email} name={r.name} /> ))} </ul> ); }
012021-04-06
相似问题