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

111
Views
No se puede leer la matriz anidada con MAP reaccionar

Estoy en problemas con mi matriz anidada. tengo un objeto:

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

cuando trato de mapear una matriz tecnológica (que es una matriz anidada) como:

 <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>

no funciona y tengo un error: Project.jsx: 67 TypeError no detectado: no se pueden leer las propiedades de undefined (leyendo 'mapa')

No sé por qué no funciona, ¿alguna idea?

Gracias :)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Tal vez en algunos objetos de la matriz, la propiedad tech no existe. Asegúrese de que se trata de una matriz definida y no de una propiedad opcional en el objeto. Por si acaso, si es una propiedad opcional o no está definida para algunos objetos en la matriz, entonces puede usar ? en tu bucle como este:

 <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>

? le permitirá evaluar el código solo si la declaración anterior ? se evalúa a un valor definido.

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