[英]how can I add unique key prop in each child in a list on react?
If movies don't have an id and you just want to get rid of the warning, you can use the second argument of the map function, which returns the index:如果电影没有 id 而你只是想摆脱警告,你可以使用 map 的第二个参数 function,它返回索引:
movieDB[movie].map((movies, index) => {
<li className='items' key={index}>
...
</li>
})
I think that every movie name is unique, so you can just我认为每一部电影的名字都是独一无二的,所以你可以
<li classname='items' key={movies.name}>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.