fix placeholder image still visible when images are loaded from Browser cache
This is a known problem. Here the code use onLoadto trigger removal of the placeholder low-res image.
Still, onLoad in never trigger by a Browser when the image is loaded from Cache.
fix placeholder image still visible when images are loaded from Browser cache
This is a known problem. Here the code use
onLoad
to trigger removal of the placeholder low-res image. Still,onLoad
in never trigger by a Browser when the image is loaded from Cache.The solution is to use .complete and a useEffect
@see https://ahndongjin.medium.com/if-image-onload-is-not-called-fe3eae74ec7f and https://stackoverflow.com/questions/59787642/nextjs-images-loaded-from-cache-dont-trigger-the-onload-event