Unverified Commit 80ec93d1 authored by Lucas Wiener's avatar Lucas Wiener Committed by GitHub

Skip warnings for Image not rendered to the dom (#32049)

Some libraries, like react-slick, render their content to a detached element before attaching it to the dom. If the content of such libraries is Image components, they will report warnings because the display/position properties are undefined. This PR squelch the warnings for such cases.
parent b6914198
......@@ -279,7 +279,9 @@ function handleLoading(
if (process.env.NODE_ENV !== 'production') {
if (img.parentElement?.parentElement) {
const parent = getComputedStyle(img.parentElement.parentElement)
if (layout === 'responsive' && parent.display === 'flex') {
if (!parent.position) {
// The parent has not been rendered to the dom yet and therefore it has no position. Skip the warnings for such cases.
} else if (layout === 'responsive' && parent.display === 'flex') {
console.warn(
`Image with src "${src}" may not render properly as a child of a flex container. Consider wrapping the image with a div to configure the width.`
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment