Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Why I get warning 'Encountered two children with the same key, `1`.' even when there are only one element in array

I have an array of comments I want to print out. But every time I keep getting this warning: "Encountered two children with the same key, '1'." even when there are only one comment in array.

How can I fix that?

let content = props.comments.map((comment) =>
        <Card key={props.product.id}  className="shadow" body>
            <p">{comment}</p>
        </Card>
    )
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Remember that map method takes (currentValue, index, arr). If props.product.id not working then use current index of item instead of a props.product.id

let content = props.comments.map((comment, index) =>
    <Card key={index}  className="shadow" body>
        <p">{comment}</p>
    </Card>
)
about 4 years ago · Juan Pablo Isaza Report

0

Another thing you could do is:

let content = props.comments.map((comment, i) =>
        <Card key={i}  className="shadow" body>
            <p">{comment}</p>
        </Card>
    )
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!