Too many next/image warning/s for non relative positioned parents #33007
-
What version of Next.js are you using?12.0.7 What version of Node.js are you using?17.2.0 What browser are you using?Chrome What operating system are you using?macOS How are you deploying your application?next dev Describe the BugIt's probably not a bug, but after updating our projects we're experiencing a huge load of warnings due to the
Working with sliders or on a modern project in general, the console gets spammed/loaded pretty fast, reducing visibility of intended logging. Expected BehaviorNo warning or at least not one warning for every single image. To ReproduceWhat's the issue about using absolute positioning in combination with layout const SlideWrapper = styled.div`
position: relative;
&::after {
content: "";
display: block;
padding-bottom: 100%;
}
`;
const ImageWrapper = styled.div`
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
`;
export const Slide: React.FC = () => {
return (
<SlideWrapper>
<ImageWrapper>
<Image src="/some/src" layout="fill" objectFit="cover" />
</ImageWrapper>
</SlideWrapper>
);
}; |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
I'm having the same problem, I'm using MUI, I've set to a Box component a class using makeStyles to declare the position relative, but it seems that it takes some time for material to add the class and the css. In my case the warning says: |
Beta Was this translation helpful? Give feedback.
-
Related: #31340 |
Beta Was this translation helpful? Give feedback.
-
hey, the workaround i found to this issue was to wrap the see code below (inline-styles for demo-purpose) ⬇️ warning: <div style={{ position: 'absolute', top: '0', left: '0' }}>
<Image src={imageSrc} layout="fill" />
</div> no warning: <div style={{ position: 'absolute', top: '0', left: '0' }}>
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
<Image src={imageSrc} layout="fill" />
</div>
</div> hope this helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback! We just released a couple fixes on the canary channel in v12.1.1-canary.1. You can try it out today with |
Beta Was this translation helpful? Give feedback.
Thanks for the feedback!
We just released a couple fixes on the canary channel in v12.1.1-canary.1.
You can try it out today with
npm install next@canary
oryarn add next@canary
.