src/components/elements/Image/image.jsx

import * as React from "react";
import PropTypes from "prop-types";

/**
 * Returms image tag with the attributes set
 *
 * @param {object} props
 * @param {string} props.src - URL of the image
 * @param {string} props.defaultSrc - Fallback src used for placeholders if src is not provided
 * @param {string} props.alt - alt text of image
 */
const Image = ({src, defaultSrc, alt, ...props}) => {
  const image = src || defaultSrc;
  return <img src={image} alt={alt} {...props} />;
};

Image.propTypes = {
  alt: PropTypes.string,
  defaultSrc: PropTypes.string,
  src: PropTypes.string,
};

Image.defaultProps = {
  alt: "",
  defaultSrc: "",
  src: "",
};

export default Image;