npm.io
1.0.1 • Published 3 years ago

react-auto-height-image

Licence
MIT
Version
1.0.1
Deps
0
Size
131 kB
Vulns
0
Weekly
0

react-auto-height-image

Avoid zero height when loading image

demo

Example: use my package on the left side

Install

yarn add react-auto-height-image
#or
npm install react-auto-height-image

Use

Use with your loading component

<AutoHeightImage
  src="https://i.picsum.photos/id/172/200/300.jpg"
  loadingComponent={<LoadingComponent />}
/>

Use with fixed height

<AutoHeightImage
  src="https://i.picsum.photos/id/172/200/300.jpg"
  defaultHeight="200px"
/>

Props


interface AutoHeightImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
  loadingComponent?: React.ReactNode,
  defaultHeight?: string,
}

Keywords