Hello everyone!
I don’t understand why I get the warning "Each child in a list should have a unique "key" prop.", despite I pass as key a unique value.
This is the error:
This is the code of TimelinePage:
const TimelinePage = () => {
return (
<section data-aos="fade-up" className="timeline-section" id="timeline" style={{paddingTop: "70px", marginTop: "-70px", marginBottom: "10px"}}>
<div className="container px-5 py-10 mx-auto">
<div className="text-center mb-20">
<div className="w-10 inline-block mb-4" style={{color: "rgba(156, 163, 175, var(--tw-text-opacity))"}}>
<img src="./timeline.svg" alt="timeline" />
</div>
<h1 className="sm:text-4xl text-3xl font-medium title-font text-white mb-4">
Percorso scolastico ed esperienze lavorative
</h1>
</div>
<div className="timeline-items">
{timelineElements.map((item) => {
return (
<div key={item.id} data-aos={item.id % 2 === 0 ? "fade-left" : "fade-right"} className="timeline-item">
<div className="timeline-dot"></div>
<div className="timeline-date">{item.date}</div>
<div className="timeline-content">
<h3 style={{marginBottom: "0px", color: "white"}}>{item.title}</h3>
<h4 style={{marginBottom: "20px", paddingTop: "0px", color: "white", fontSize: "16px"}} className="timeline-subtitle">{item.location}</h4>
<p>{item.description}</p>
</div>
</div>
)
})}
</div>
</div>
</section>
);
};
This is the array "timelineElements" (with some information eliminated for privacy):
export const timelineElements = [
{
id: 1,
title: "Diploma in Sistemi Informativi Aziendali",
location: "",
description:
"",
date: ""
},
{
id: 2,
title: "Programmatore",
location: "",
description:
[""],
date: ""
},
{
id: 3,
title: "Corso di Laurea Triennale in Informatica",
location: "Università degli studi di Torino",
description:
"",
date: ""
},
{
id: 4,
title: "Programmatore",
location: "",
description: [""],
date: ""
},
{
id: 5,
title: "Corso di Laurea Magistrale in Informatica",
location: "Università degli studi di Torino",
description:
"",
date: ""
}
];
What can i do to delete this warning?
Thanks in advance!
` element not present in your question. Have you perhaps redacted too much? – Phil Mar 10 '22 at 00:50
in my TimelinePage, that's the problem... I really don't understand where the problem come from – BlowLore Mar 10 '22 at 00:53