0

My NextJS 12 App is stuck loading when the image provided doesn't exist, there is a way to solve that?

import Image from "next/image";

export default function Home() {
  return (
    <div>
      <Image
        src="/image_dont_exist"
        alt="Image don't exist"
        width={400}
        height={400}
        objectFit="cover"
      />
    </div>
  );
}

The page just keep loading forever

Freddx L.
  • 455
  • 2
  • 7
  • 16
  • 1
    Refer this : https://stackoverflow.com/questions/66949606/what-is-the-best-way-to-have-a-fallback-image-in-nextjs - It extends the image to go to a fallback – Ramakay Nov 24 '21 at 21:26
  • 1
    Your code is working, for my test: your code tries to load image, then showing alt text. What do you expect? – illia chill Nov 25 '21 at 10:22

0 Answers0