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

113
Vistas
Can't read nested Array with MAP react

i'm in trouble with my nested array. i have an object :

{ name: 'house', 
  url: 'www.mockhouse.com', 
  thumb: myImage, 
  describe: 'another project', 
  tech: ['react', 'fetch', 'SASS', 'HTML'] },

when i try to map tech array (that is a nested array) like :

   <GalleryWrapper>
    {props.projectArray.map((projects) => {
      return (
        <ThumbWrapper key={uuidv4()}>
          <ThumbImg src={projects.thumb} alt="" />
          <ThumbTitle> {projects.name}</ThumbTitle>
          <ThumbDescrib>{projects.describe}</ThumbDescrib>

          {projects.tech.map((techno) => {
            return <ThumbTech>{techno}</ThumbTech>; // here is the problem //
          })}

        </ThumbWrapper>
      );
    })}
  </GalleryWrapper>

it dosen't work and i have an error : Project.jsx:67 Uncaught TypeError: Cannot read properties of undefined (reading 'map')

i dont know why it dosen't work any idea ?

thanks :)

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Maybe in some objects of the array the tech property does not exist. Please make sure this is a defined array and not an optional property in the object. Just in case, if it is an optional property or it is undefined for some objects in the array then you can use ? on you loop like this:

   <GalleryWrapper>
    {props.projectArray.map((projects) => {
      return (
        <ThumbWrapper key={uuidv4()}>
          <ThumbImg src={projects.thumb} alt="" />
          <ThumbTitle> {projects.name}</ThumbTitle>
          <ThumbDescrib>{projects.describe}</ThumbDescrib>

          {projects.tech?.map((techno) => {
            return <ThumbTech>{techno}</ThumbTech>; // here is the problem //
          })}

        </ThumbWrapper>
      );
    })}
  </GalleryWrapper>

? will allow you to evaluate the code only if the statement before ? evalues to a defined value.

about 4 years ago · Santiago Trujillo 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