Last active
May 29, 2020 18:26
-
-
Save jamiejohnsonkc/49c709bd03f69893d1caad2b1de1b1d4 to your computer and use it in GitHub Desktop.
Query single fluid Gatsby Image to Component.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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