0

I am trying to display a small image in a gatsby app, however, I am not able to figure out the error here.

Code

import React from "react"
import Img from "gatsby-image"
import { graphql } from "gatsby"

const Footer = ({ data }) => (
  <div>
    <h1>Hello gatsby-image</h1>
    <Img fluid={data.footerHeart.file.childImageSharp.fluid} alt="footer" />
  </div>
)

export default Footer

export const query = graphql`
  query {
    footerHeart: file(relativePath: { eq: "love.png" }) {
      childImageSharp {
        fluid(maxWidth: 40) {
          ...GatsbyImageSharpFluid
        }
      }
    }
  }
`

Error error

sayamkanwar
  • 49
  • 1
  • 10

1 Answers1

0

You have defined an entry point to your file field So use that entry point as the direct path like so <Img fluid={data.footerHeart.childImageSharp.fluid} alt="footer" />

Raincat x
  • 1
  • 1