gatsby usestaticquery variable code example
Example 1: usestaticquery gatsby
import { useStaticQuery, graphql } from "gatsby"
Example 2: passing variable in usestaticquery
// Using StaticQuery instead of useStaticQuery
import React from "react"
import Img from "gatsby-image"
import { StaticQuery } from "gatsby"
export default ({ src }) => {
<StaticQuery
query={graphql`
query HeadingQuery($src: String!) {
File(relativePath: { eq: $src }) {
childImageSharp { ...etc }
}
`}
render={data => (
<Img fixed={data.path.to.query} />
)}
/>
}