Code Monkey home page Code Monkey logo

Comments (13)

RyanClementsHax avatar RyanClementsHax commented on July 24, 2024 9

Thank you all for your patience! I'm working with Next.js to figure out what the issue exactly is and how to remediate it

from storybook-addon-next.

RyanClementsHax avatar RyanClementsHax commented on July 24, 2024 8

So it seems that the following code no longer works

// .storybook/preview.js
import * as NextImage from "next/image";

const OriginalNextImage = NextImage.default;

Object.defineProperty(NextImage, "default", {
  configurable: true,
  value: (props) => <OriginalNextImage {...props} unoptimized />,
});

This has been the convention to getting next/image working in storybook for a long time. I'm not sure why it is broken now. This is a compare between next 12.1.4 and 12.1.5 and nothing stands out to me as a major change.

I will continue to look into this, but if anyone has any insight, feel free to chip in.

A more detailed explanation for why this error is occurring is that when optimized={true} on next/image, the loader logic is run and thus creates the problems you are seeing. Because the code that automatically turns this off for you no longer works, you are seeing this error.

from storybook-addon-next.

hhimanshu avatar hhimanshu commented on July 24, 2024 7

I can confirm that after updating to 1.6.4, images rendered correctly on storybook local, and production builds. And also on Chromatic

"storybook-addon-next": "1.6.4"

from storybook-addon-next.

RyanClementsHax avatar RyanClementsHax commented on July 24, 2024 5

I might put it in the repo but I was hoping to have clarification from the nextjs team if this is a bug on their end first.

I'm kinda torn on what to do. Put a workaround in this repo and risk breaking changes for y'all if nextjs decides to fix this problem, or wait until a decision is reached so we can implement a proper fix if needed.

from storybook-addon-next.

RyanClementsHax avatar RyanClementsHax commented on July 24, 2024 4

Thanks all for your patience. I know this was frustrating.

from storybook-addon-next.

RyanClementsHax avatar RyanClementsHax commented on July 24, 2024 3

Update:

There is a tentative workaround here. It should be good enough for most use cases

from storybook-addon-next.

RyanClementsHax avatar RyanClementsHax commented on July 24, 2024

Thanks for opening the issue! Do you currently have a workaround?

from storybook-addon-next.

rsanchez avatar rsanchez commented on July 24, 2024

No workaround currently, other than just using Next 12.1.4. Seems like maybe a lot of changes under the hood to next/image in 12.1.5.

from storybook-addon-next.

LZL0 avatar LZL0 commented on July 24, 2024

I am experiencing the same issue. I was wondering why, but @rsanchez is probably correct.

from storybook-addon-next.

jeroenroumen-acc avatar jeroenroumen-acc commented on July 24, 2024

Experiencing the same issue. Reverting to 12.1.4 for now seems to solve it.

from storybook-addon-next.

LoicMahieu avatar LoicMahieu commented on July 24, 2024

Like @jeroenroumen-acc , rollback to 12.1.4 fix the issue...

from storybook-addon-next.

rsanchez avatar rsanchez commented on July 24, 2024

@RyanClementsHax Thanks for tracking this down. Is that fix something you plan to incorporate into this plugin? Or are you suggesting we use that fix in our own code?

from storybook-addon-next.

github-actions avatar github-actions commented on July 24, 2024

🎉 This issue has been resolved in version 1.6.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

from storybook-addon-next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.