From b6b5207979370c244e32977c87242064f067842c Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Thu, 3 Dec 2020 18:30:38 +0100 Subject: [PATCH] fix(gatsby-plugin-image): don't show hydration warning (#28407) Co-authored-by: Matt Kane Co-authored-by: gatsbybot --- .../src/components/gatsby-image.browser.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/gatsby-plugin-image/src/components/gatsby-image.browser.tsx b/packages/gatsby-plugin-image/src/components/gatsby-image.browser.tsx index b03defdc43607..42a014e2b48ff 100644 --- a/packages/gatsby-plugin-image/src/components/gatsby-image.browser.tsx +++ b/packages/gatsby-plugin-image/src/components/gatsby-image.browser.tsx @@ -143,9 +143,15 @@ export const GatsbyImageHydrator: FunctionComponent = function const hasSSRHtml = root.current.querySelector(`[data-gatsby-image-ssr]`) // On first server hydration do nothing if (hasNativeLazyLoadSupport() && hasSSRHtml && !hydrated.current) { + hydrated.current = true return } + // When no ssrHtml is found (develop) we should force render instead of hydrate + if (!hasSSRHtml) { + hydrated.current = true + } + import(`./lazy-hydrate`).then(({ lazyHydrate }) => { lazyHydrator.current = lazyHydrate( {