-
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
fix(gatsby-plugin-image): Hide placeholder on hydrated components with loaded images #29333
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes the issue but it's actually a little bit of a sideEffect, none the less I don't see any issues with it. I would like to see tests to actually catch this in the future.
Something to consider to not have these sideEffects anymore is to wrap the GatsbyImage component in gatsby-image.browser.tsx with React.memo
so we don't re-trigger the component when we don't have to.
To reproduce what this PR fixes is to simply add a React.useState & React.useEffect
to your page.
const [data, setData] = React.useState(null)
React.useEffect(() => {
setTimeout(() => {
setData("test")
}, 1000)
},)
Co-authored-by: gatsbybot <mathews.kyle+gatsbybot@gmail.com> (cherry picked from commit 1443ecd)
Published in |
Thank you @ascorbic, this fixed the issue for me. |
@ascorbic Is this supposed to be fixed in I'm still experiencing the same issue when using |
@sandren It's not in next yet. I'll do a release tomorrow |
This feature (and release 0.7.1) didn't end up in the changelog? |
We need to allow handling of "loaded" tracking when already hydrated. We also need to pass loading=lazy to browser components, not just server. Fixes an issue where navigating between pages that shared images was causing the placeholder to never be hidden.