Next.js Discord

Discord Forum

Image with src is missing required "width" property

Answered
Cimarrón Uruguayo posted this in #help-forum
Open in Discord
Cimarrón UruguayoOP
      <div className="col-start-1 row-start-2 overflow-hidden rounded-xl bg-neutral-100 sm:col-span-5 sm:row-span-full sm:rounded-3xl">
        <Image
          alt=""
          {...image}
          sizes="(min-width: 1024px) 17.625rem, (min-width: 768px) 16rem, (min-width: 640px) 40vw, 3rem"
          className="h-12 w-12 object-cover grayscale sm:aspect-[7/9] sm:h-auto sm:w-full"
        />
      </div>


Where the variable image is of type Omit<ImageProps, 'alt'> & { alt?: string }. I don't want to hardcode any width or height properties on the Image component. I believe the className handles the sizing already, so how can i resolve this error?
Answered by Cimarrón Uruguayo
just had to add height={0} width={0}
View full answer

2 Replies

Cimarrón UruguayoOP
nevermind i fixed it
Cimarrón UruguayoOP
just had to add height={0} width={0}
Answer