Skip to content

Instantly share code, notes, and snippets.

@hrdtbs
Created April 16, 2021 07:03
Show Gist options
  • Save hrdtbs/aa1d7cc81633d01fdffa80e0c492607d to your computer and use it in GitHub Desktop.
Save hrdtbs/aa1d7cc81633d01fdffa80e0c492607d to your computer and use it in GitHub Desktop.
How to mock Next.js image component & Next.js link component in Storybook
import * as NextImage from "next/image"
const OriginalNextImage = NextImage.default
Object.defineProperty(NextImage, "default", {
configurable: true,
value: props => <OriginalNextImage {...props} unoptimized />
})
import * as NextLink from "next/link"
const OriginalNextLink = NextLink.default
Object.defineProperty(NextLink, "default", {
configurable: true,
value: props => <OriginalNextLink {...props} prefetch={false} />
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment