import React from 'react'; import { StyledComponent } from '@emotion/styled'; import Img from 'gatsby-image'; import { StaticQuery, graphql } from 'gatsby'; import BackgroundImage from 'gatsby-background-image'; interface ImageProps { fluid: any; isBackground?: boolean; classId?: string; styledComponent?: StyledComponent; } class Image extends React.Component { static defaultProps = { isBackground: false }; renderBackground = (fluid: any) => { const { styledComponent: StyledBackground } = this.props; return StyledBackground ? : } render(): JSX.Element { return ( { const placeholder = file.childImageSharp; const { fluid, isBackground } = this.props; const hasFluidImage = fluid && fluid !== null; const imageUrl = hasFluidImage ? fluid.fluid : placeholder.fluid; return isBackground ? this.renderBackground(fluid) : ; }} /> ); } } export default Image;