Gatsby: Can't get my images from markdown frontmatter to display - "Cannot read property 'src' of undefined

Created on 7 Feb 2019  路  5Comments  路  Source: gatsbyjs/gatsby

Here is my query and how I'm rendering a card component... Using images because my preview did not show indenting and made it super hard to read.

screen shot 2019-02-07 at 10 37 41 am

When I console log pic I I get the correct image object... but when I pass it as a prop and try to display it, I get the error TypeError: Cannot read property 'src' of undefined.

screen shot 2019-02-07 at 10 35 46 am

Here is my card component that is displaying this data...

screen shot 2019-02-07 at 10 38 40 am

PictureWrapper is a styled Gatsby Image using styled components so I can give it a border radius and the exact width I want.

When I take the picture out of the component, everything displays correctly. So I'm not sure why the image is not.

Gatsby version: 2.0.76

stale? needs reproduction question or discussion

Most helpful comment

Try

const PictureWrapper = styled(Img)

All 5 comments

Try

const PictureWrapper = styled(Img)

@t2ca Thanks. I imported Image from 'gatsby-image'

I thought you can name default exports whatever you wanted. I guess I was wrong.

But then why do my images work on all my other pages where I'm just querying the image?

@danboyle8637 It _is_ a default export and you should be able to name it anything you like. I'm not sure what the issue here is but I can't seem to reproduce it.

Can you link to a minimal reproduction if possible?

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Hey again!

It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.

Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalinchernev picture kalinchernev  路  3Comments

hobochild picture hobochild  路  3Comments

brandonmp picture brandonmp  路  3Comments

andykais picture andykais  路  3Comments

rossPatton picture rossPatton  路  3Comments