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

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

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