Gatsby passing img in props

Hello everyone! i have a question about Gatsby, specifically about how to import imagess if i’m using an JS object because I’m passing it through a prop (look at code-column n°1, literal object in N°2) in the 3rd column is the whole component with all the object being called.

in Gatsby documentation say that we need to impor the img or SVG but in this case i can’t. Anyone know how to deal in this case?

Thanks in advance!

Hi Ricardo

Were you able to figure it out? I am curious about how you handled it :wink:

If I understand your case correctly, you have a fixed array containing the image. But now you cannot pass it through Gatsby Img. I only have experience with images in frontmatter which are then passed through graphql as you can trigger child image sharp there (not the main reason why I use frontmatter). Guess it should be possible to convert your array to JSON (if it is static) and then use gatsby-transformer-json so that you can query it. But may be overkill (or not even a solution in your case). Or you could maybe use hooks?

Anyway I would love to hear about the progress you made!

1 Like

Somebody help me in StackOverflow: here the solution.

1 Like