Files
StevenandGitHub 9cf2a3273d fix(next/image): improve warning when fill and sizes="100vw" (#61949)
Previously, this error was confusing because it made it sound like the
`sizes` prop was missing. This was because the default value of `sizes`
is `100vw` so the previous code couldn't tell the different between
implicit vs explicit `100vw`.

This PR changes the code to read the input value from the `sizes` prop
and prints a better warning.


Fixes NEXT-2441
2024-02-12 17:32:39 +00:00

42 lines
947 B
JavaScript

import React from 'react'
import Image from 'next/image'
const Page = () => {
return (
<div>
<h1>Fill Mode</h1>
<div
id="image-container-1"
style={{
height: '300px',
width: '300px',
position: 'relative',
overflow: 'hidden',
}}
>
<Image id="fill-image-1" src="/wide.png" fill />
</div>
<div id="image-container-2">
<Image id="fill-image-2" src="/wide.png" fill />
</div>
<div
id="image-container-3"
style={{
position: 'relative',
overflow: 'hidden',
}}
>
<Image id="fill-image-3" src="/wide.png" fill />
</div>
<div
id="image-container-4"
style={{ position: 'relative', width: '30vw', height: '30vw' }}
>
<Image id="fill-image-4" src="/test.png" sizes="100vw" fill />
</div>
</div>
)
}
export default Page