I understand that you cannot pass the source of an image to the StaticImage component as the result of a function. However, can anyone explain to me the difference between these two examples.
import React from 'react'
import { StaticImage } from 'gatsby-plugin-image' // to take image data and render it
export default function Example() {
const imageSrc = '../images/jonathan-adams.jpg'
const data = {
imageSrc: '../images/jonathan-adams.jpg',
}
return (
<div>
<StaticImage src={imageSrc} alt="alt text" /> {/* works */}
<StaticImage src={data.imageSrc} alt="alt text" /> {/* doesn't work */}
</div>
)
}
One is a direct variable reference, and the latter is referencing the same value, but through dot notation. Is dot notation a function?