react-use-img
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Use Img

npm version GitHub license GitHub stars

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

Package Sidebar

Install

npm i react-use-img

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

6.22 kB

Total Files

7

Last publish

Collaborators

  • vascobotelho