import React from 'react' import PropTypes from 'prop-types' import { CX } from '../constants' class Image extends React.PureComponent { state = { error: false, } handleOnError = () => { this.setState({ error: true }) } render() { const { alt, src, fit, className, nullable, isLazy, imageRef, ...otherProps } = this.props const { error } = this.state const classes = CX(className, { d: 1, objectFitCover: !!src && fit === 'cover', bgSecondary: !src, }) //If error and not our own image if (error && nullable) { return null } if (!src) { return (
) } return (