-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gatsby Images not showing on first load when using Styled Components #21130
Comments
You just have a styling issue. Everything is working as expected with gatsby image. When using fluid images, they will stretch to fill the container. The container is defined by the content within it but because you're using fluid widths, it's got nothing to guide it. If you add text below you should see that the image will appear above because it now has some guiding content to use. To fix this, you can set the article to have a |
@danspratling Thank you for the reply! I added The article tag is not even including the styling at all. |
Just checked your repo. It looks like you weren't including the plugin in the |
Oh wow, it works now! Thank you so much for your help @danspratling !! |
I'm not entirely sure. My guess would be that gatsby is doing something in the build phase which means that some components are being pre-generated (using gatsby-config.js) and styled components isn't being used at this point (after all, it just ends up as css in the end). Maybe This is just a guess though. I don't know the inner workings of gatsby or styled-components well enough to say anything for certain about the specific reasons behind this problem. Glad it's working now though! |
Description
Hi everyone,
I set up a gatsby blog site using blog starter and hooked it up to Netlify CMS. I am having an issue with displaying images on the index page.
When the page first loads, none of the images on index page would show. If I navigate to other pages and come back to the index, it all appears. It is happening on live site and works fine in dev environment. All images are being sent from CMS as markdown file.
I followed an instruction on here: #3545
and ran
yarn add git://github.com/lfittl/hast-to-hyperscript
but it didn’t fix:(I have asked this in Netlify community but was told to open an issue here since this is a bug on Gatsby side.
Live site:
Dev environment:
Thank you and please let me know if there's anything else I can provide.
Steps to reproduce
Here’s the link to the site: https://hardcore-wiles-235b68.netlify.com
I was able to get images to show up by inserting a style tag to the article element like this:
<article style={{ width:
50%}} key={node.fields.slug}>...</article>
but if I use styled components:
the styling gets ignored and image and wrapping div width is set to 0.
Also, jlengstorf at Netlify community pointed out that Gatsby is adding
aria-hidden
attributes and not respecting the height/width.I have ran
gatsby build
andgatsby serve
to serve it locally but no images showed on first load.Repo for this project: https://github.com/hoshikitsunoda/blog-gatsby-netlifycms
Expected result
It should show all the images when the page loads.
Actual result
No images are shown. Image data is there but the dimension is set to 0x0.
Environment
Update(02-03-2020): I swapped the element from
article
to regulardiv
styled withstyled components
, still no image shown.The text was updated successfully, but these errors were encountered: