useImage
Minimal React Hook to load images!
Minimal React Hook to load images!
yarn add react-hook-image
npm i react-hook-image
import useImage from "react-hook-image";
export default function ImageComponent({ imageUrl }) {
const { src, status } = useImage(imageUrl, "Anonymous");
return status === "loading" ? <div>Loading ...</div> : <img src={src} alt="alt text" />
});
Hook status: loading
, success
, failed
Arguments | Required? |
---|---|
url | Yes |
crossOrigin | No |
Licensed under the MIT License