【发布时间】:2021-07-20 22:29:37
【问题描述】:
我正在做一个应用程序,在前端我使用反应,每当我使用地图功能时,我都会收到这些错误。
你会想……嗯,那是因为你没有为你的容器设置任何密钥,而事实是,我做到了……但是错误不断出现。
让我给你看代码
{specificPhotos.map((photo, i) => {
return (
<>
{/* The Photo */}
<PhotoWrapper key={photo.id}>
{/* For Images */}
{photo.photo.charAt(5) === "i" && (
<img src={photo.photo} />
)}
{/* For Videos */}
{photo.photo.charAt(5) === "v" && (
<>
<video src={photo.photo} />
</>
)}
{/* For Videos Too */}
{photo.photo.charAt(5) === "v" && (
<>
<VideoPlay>
<VideoPlayIcon />
</VideoPlay>
</>
)}
另外一次我也使用了map fn
{singlePhoto.comments.map(comment => {
return (
<>
<ContainComment key={comment.id}>
{/* Photo */}
<PresentationImg
style={{ width: "100%", maxHeight: "50px" }}
area="perfil"
>
<CommentPresentation>
<img src={comment.presentation} />
</CommentPresentation>
</PresentationImg>
{/* Body */}
<TheComment>
<h2>
{comment.user} <span>{comment.body}</span>
</h2>
</TheComment>
那么,我应该在哪里处理密钥?也许我做错了什么...我不知道,请帮助我并感谢您的时间!
【问题讨论】:
-
通过console.log检查是否存在ID。
标签: reactjs