score:0

ensure your images prop is actually an array. can you do some debugging to figure out what your images object actually is?

using proptypes is a way to have react help, and if it is nullable (i.e. not isrequired), then use a guard on it:

import react from "react";
import proptypes from 'prop-types';
import image from "./image";

const proptypes = {
  images: proptypes.arrayof(
    proptypes.shape({
      id: proptypes.string.isrequired, // used as key
      src: proptypes.string.isrequired, // used for image source
      <... other object properties ...>
    })
  ),
};

const images = ({ images }) => {
  const images = images && images.map((image) => {
    return <image key={image.id} image={image}/>
  });

  return <div classname="images">{images}</div>;
}

images.proptypes = proptypes;

export default images;

Related Query

More Query from same tag