DEV Community

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

Collapse
 
jonasmerlin profile image
Jonas Schumacher

Something might have changed since I wrote the post. Can you tell me more specifics? What is not working exactly? Do you get any error messages? Then I will try to update the post.

Collapse
 
burdiuz profile image
Oleg Galaburda

Didn't work for me either. What worked for me is providing defaultProps with unoptimized = true in "preview.js"

import Image from 'next/image';

Image.propTypes = {
  unoptimized: null,
};

Image.defaultProps = {
  unoptimized: true,
};
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
pmfeo profile image
Pablo

Thank you both, guys! Oleg's tweak was needed as well in to make it work properly ("next": "12.1.6" + "@storybook/react": "^6.5.9")

Thread Thread
 
jonasmerlin profile image
Jonas Schumacher • Edited

Hey! Sorry, I'm currently working with neither next nor storybook anymore and frankly, don't have the time right now to go into this and comprehend what is going on. Still, this post seems to be pretty popular and I'd like it to be at least correct and runnable when people find it. Would you be willing to suggest the necessary changes to my post to make it map to what you had to do? I would then change the necessary parts and mark you as contributors. Would be really cool!