New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-use-image

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-image

A react hook for pre-loading images.

  • 0.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
37
decreased by-38.33%
Maintainers
1
Weekly downloads
 
Created
Source

react-use-image

A react hook for pre-loading images.

install it

npm i react-use-image

# or

yarn add react-use-image

use it

import useImage from 'react-use-image';

const Example = ({ src }) => {
  // use the hook
  // pass it an image source url
  const { loaded } = useImage(src);

  if (!loaded) return null;

  return <img src={src} alt="Example" />;
};

input

Image URL, e.g. https://foo.com/cat.jpg

return values

{
  "loaded": false, // image found and loaded
  "failed": false, // image not found

  // actual size of the image
  "dimensions": {
    "width": 0, // width of image in pixels
    "height": 0 // height of image in pixels
  }
}

Docs

  • Storybook coming soon

Authoer

Joe Seifi

Licence

MIT

FAQs

Package last updated on 03 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc