react-use-img
v1.0.0
Published
A hook for lazy loading images in React
Downloads
8
Maintainers
Readme
Use Img
Description
A hook for lazy loading images
Installation
npm install react-use-img
Usage
import { useImg } from 'react-use-img';
function App() {
const { isLoading, isError, img } = useImg('https://via.placeholder.com/56x56', 56);
if (isLoading) return <span>Loading...</span>;
if (isError) return <span>Error</span>;
return <img {...img} alt="..." />
}
License
MIT