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

119
Vistas
My map gives me Cannot read properties of undefined (reading 'map')

I try to do a map of my differents people but it gives me the error on the title

I don't really understand and there is my code:


export const Testt = ({ childs}) => {
    console.log(childs)
    return childs.map((element, index) => (
        //element

        <div>
            zdijiziojzadioj
        </div>
    )
    )
    }

and there is my childs

(12) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
0: {_id: '619e7301e74b007f5c62482d', firstName: '', lastName: '', birth: '2020-11-19', genre: 'male', …}
1: {_id: '619fae3c96f85d2415d8fe24', firstName: '', lastName: '', birth: '2021-11-03', genre: 'male', …}
2: {_id: '619fae5296f85d2415d8fe28', firstName: '', lastName: '', birth: '2021-11-04', genre: 'male', …}
3: {_id: '619faec296f85d2415d8fe39', firstName: '', lastName: '', birth: '2021-11-04', genre: 'male', …}
4: {_id: '619faee196f85d2415d8fe40', firstName: '', lastName: '', birth: '2021-11-04', genre: 'male', …}
5: {_id: '619faf1496f85d2415d8fe4e', firstName: '', lastName: '', birth: '2021-11-04', genre: 'male', …}
...
length: 12

I don't understand where can be the problem, i already used the map but i have never had this problem,

Thanks for yours answer!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Probably means that the value childs is not populated at the initial render.

What we usually do in React to circumvent this, is adding conditional statements.

This should do the trick -

export const Testt = ({ childs}) => {
    console.log(childs)
    return childs && childs.map((element, index) => (
        //element

        <div>
            zdijiziojzadioj
        </div>
    ))
}
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