Gatsby: imported image not showing up and logging as undefined...

Created on 6 Oct 2019  路  2Comments  路  Source: gatsbyjs/gatsby

I have an image that I am importing into a page, like so:

import React from 'react'

import { PlayButton } from '../images/controls/play-button.svg'

console.log(PlayButton)

const IndexPage = () => (
  <>
    <img src={PlayButton} alt="Play Button"/>
  </>
)

export default IndexPage

...and I have verified that the path is correct. But the image is not showing up on the site, only the alt text. The console log also comes back as undefined. Not sure what I need to do. Even if I specify a specific size via css it still does not show up. This seems quite odd, I would think, and I can't figure out why it's not working.

Any thoughts?

Most helpful comment

@rchrdnsh try removing the {} symbols around PlayButton and see if it works then:

import PlayButton from '../images/controls/play-button.svg'

All 2 comments

@rchrdnsh try removing the {} symbols around PlayButton and see if it works then:

import PlayButton from '../images/controls/play-button.svg'

AHHH!!! I knew I was missing something dumb! Thank you! XD

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ferMartz picture ferMartz  路  3Comments

rossPatton picture rossPatton  路  3Comments

andykais picture andykais  路  3Comments

magicly picture magicly  路  3Comments

dustinhorton picture dustinhorton  路  3Comments