Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda