Components
Image
Image helps you display the image in an optimal manner. By default, it waits up to 5 seconds (configurable) for an image resource to fully load before displaying it, mitigating display issues with certain formats like baseline JPEGs. If loading exceeds 5 seconds, the component will display the partially-loaded image anyway to indicate progress.
Usage
function Image() {
return (
<Image
alt=""
src="https://image-demo-1200px.jpg"
width={1600}
height={900}
srcSet="
https://image-demo-200px.jpg 200w,
https://image-demo-600px.jpg 600w,
https://image-demo-1200px.jpg 1200w,
"
sizes="(min-width:640px) 330px, 80vw"
placeholder="data:image/webp;base64,UklGRuYAAABXRUJQVlA4INoAAADwBwCdASpkAEMA"
/>
)
}
Behaviors
There is no difference in behavior between the hydrated and unhydrated modes.
A timer is set when the HTML is parsed. By default, if the image fully loads within 5 seconds (configurable), it will be displayed all at once. This approach helps to prevent display issues associated with certain image formats, such as baseline JPEGs.
If the loading time exceeds 5 seconds, the partially-loaded image will be displayed regardless of how much data has been loaded. This ensures that users are not stuck viewing the placeholder, keeping them informed about the image's loading progress.