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

108
Views
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 answers
Answer question

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