Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jamiejohnsonkc/49c709bd03f69893d1caad2b1de1b1d4 to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/49c709bd03f69893d1caad2b1de1b1d4 to your computer and use it in GitHub Desktop.
Query single fluid Gatsby Image to Component.jsx
import React from 'react'
import { useStaticQuery, graphql } from 'gatsby'
import Img from 'gatsby-image'
const data = useStaticQuery(graphql`
query {
file(relativePath: { eq: "bookshelf.jpg" }) {
childImageSharp {
fluid {
base64
aspectRatio
src
srcSet
sizes
}
}
}
}
`)
const ImageTest2 = () => {
return (
<Img
fluid={data.file.childImageSharp.fluid}
alt='A corgi smiling happily'
/>
)
}
export default ImageTest2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment