DEV Community

Cover image for Fixing Common Errors in React Projects (and Why They Happen)
Ehtashamul Mahim
Ehtashamul Mahim

Posted on

Fixing Common Errors in React Projects (and Why They Happen)

  1. Cannot read properties of undefined (reading 'map') ** Why it happens:** You’re trying to .map() over an array — but the array is either:

undefined at the time of rendering

Not properly initialized

`{socialMedia?.map((item, index) => (

{item.name}
))}

// OR

{(socialMedia || []).map((item, index) => (

{item.name}

))}

`

Top comments (0)