DEV Community

Discussion on: How to Use the Next.js Image Component in Storybook

Collapse
 
damsalem profile image
Dani Amsalem

Very, very helpful! I'm also using Sanity.io as a CMS and had to use a fallback prop since I'm not passing in JSON data for each image. If anyone else wants to know what I did, I just used the OR operator like so:

<Image
  src={storyHero || urlFor(heroImage.url).auto("format").size(600, 338).url()}
  alt={storyAlt || heroImage?.alt}
  width={600}
  height={338}
  layout={"responsive"}
/>
Enter fullscreen mode Exit fullscreen mode