solution

Resolve Cannot Read Property ‘map’ of Undefined on React.js

At the time of initialization of your component it is possible that all your props are not hydrated at first rendering. If you use a loop in your render and rely on a poorly initialized array to iterate on it, this may raise an error. Here is how to check that your array is well structured to iterate on it without getting an error.


if (Array.isArray(this.props.myPropsArray)) {
  this.props.myPropsArray.map((item) => {
    return (
        <p>{item}</p>
    );
  });
}