A hook for lazy loading images
npm install react-use-img
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="..." />
}
MIT