-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[bug] image isLoaded state was being set to false after it was set to true … #1618
Conversation
…by the onLoad function
This pull request is automatically deployed with Now. Latest deployment for this branch: https://pwa-studio-git-sirugh-fix-image-placeholder-state.magento.now.sh |
If your PR is missing information, check against the original template here. At a minimum you must have the section headers from the template and provide some information in each section. |
// On mount, reset loaded to false. | ||
useEffect(() => { | ||
setIsLoaded(false); | ||
}, [src]); |
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.
This is not just on the mount but for all cases when src
changes. Makes sense because when src
changes, image need to be re-fetched. But since we are not handling the fetch part, it is safe to remove this block of code.
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.
Right! Thank you for that.
This might be the reason why images fail to load on smaller devices in case #1584. |
Image
isLoaded
state was incorrectly being set tofalse
. This PR removes the effect that was, for some reason, doing that. We don't need to set state to false on mount because that's the default state of theuseState
.The reason this occurs on
develop
locally is that the images are loaded fast enough that the mount effect was happening after the load, which means we setisLoaded
totrue
and then we trigger the effect which setsisLoaded
tofalse
.This is definitely a bug and will be seen with a fast image server.
BEFORE
AFTER