From 58c161c99bc400ab2c1553afc476cdddeceffa46 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sat, 24 Oct 2020 17:23:42 +0200 Subject: [PATCH] Fix flashing of no-src image when using next/image (#18195) Solves on of the issues in https://github.com/vercel/next.js/issues/18122 --- packages/next/client/image.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/next/client/image.tsx b/packages/next/client/image.tsx index 69ad812509c68a7..80fb05cd9f34d01 100644 --- a/packages/next/client/image.tsx +++ b/packages/next/client/image.tsx @@ -64,6 +64,7 @@ function getObserver(): IntersectionObserver | undefined { if (lazyImage.dataset.srcset) { lazyImage.srcset = lazyImage.dataset.srcset } + lazyImage.style.visibility = 'visible' lazyImage.classList.remove('__lazy') cachedObserver.unobserve(lazyImage) } @@ -251,6 +252,7 @@ export default function Image({ paddingBottom: `${ratio}%`, } imgStyle = { + visibility: lazy ? 'hidden' : 'visible', height: '100%', left: '0', position: 'absolute',