1.0.0 • Published 2 years ago
react-use-img v1.0.0
Use Img
Description
A hook for lazy loading images
Installation
npm install react-use-imgUsage
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
1.0.0
2 years ago