Unverified Commit d196e72a authored by Tadao Iseki's avatar Tadao Iseki Committed by GitHub

Export ImageProps from Image component (#18576)

This allows to import the type `ImageProps` from `next/image` like `next/link`.

https://github.com/vercel/next.js/blob/a6660729ea82fbcb26cfe7c89637b1af37255c9f/packages/next/client/link.tsx#L21

## Usage

```tsx
import Image, { ImageProps } from 'next/image'

const CustomImage: React.FC<ImageProps> = (props) => (
  <Image {...props} unsized />
)
```
parent 3cece4d2
...@@ -34,7 +34,7 @@ type ImageData = { ...@@ -34,7 +34,7 @@ type ImageData = {
type ImgElementStyle = NonNullable<JSX.IntrinsicElements['img']['style']> type ImgElementStyle = NonNullable<JSX.IntrinsicElements['img']['style']>
type ImageProps = Omit< export type ImageProps = Omit<
JSX.IntrinsicElements['img'], JSX.IntrinsicElements['img'],
'src' | 'srcSet' | 'ref' | 'width' | 'height' | 'loading' | 'style' 'src' | 'srcSet' | 'ref' | 'width' | 'height' | 'loading' | 'style'
> & { > & {
......
import React from 'react'
import Image, { ImageProps } from 'next/image'
export default () => {
const props: ImageProps = {
src: '/noop.jpg',
width: 100,
height: 100,
}
const filledProps: ImageProps = {
src: '/noop.jpg',
layout: 'fill',
}
return (
<>
<Image {...props} />
<Image {...filledProps} />
</>
)
}
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import React from 'react' import React from 'react'
import { hello } from '../components/hello' import { hello } from '../components/hello'
import Image from '../components/image'
import Link from '../components/link' import Link from '../components/link'
import Router from '../components/router' import Router from '../components/router'
import { World } from '../components/world' import { World } from '../components/world'
...@@ -25,6 +26,7 @@ export default function HelloPage(): JSX.Element { ...@@ -25,6 +26,7 @@ export default function HelloPage(): JSX.Element {
{hello()} <World /> {hello()} <World />
<Router /> <Router />
<Link /> <Link />
<Image />
</div> </div>
) )
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment