1.0.1 • Published 2 years ago

react-auto-height-image v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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,
}