Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 685 Bytes

File metadata and controls

44 lines (30 loc) · 685 Bytes
useImage
Minimal React Hook to load images!

Install

Yarn
yarn add react-hook-image
NPM
npm i react-hook-image

Usage

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

License

Licensed under the MIT License