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

react-imgp

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-imgp

React component for preloading images

  • 5.0.4
  • latest
  • Source
  • npm
  • Socket score

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

react-imgp canvas

Usage

import { Image } from 'react-imgp';

const App = ({ imageProps }) => <Image {...imageProps} />;

API

  • Use it as a react component that takes the same props as the HTMLImageElement and passes them down

    • src - Same as the HTMLImageElement. It is required.
    • fallback - Used in case the original src cannot be retrieved.
    • loader - If provided, it will be displayed while the image loads.
  • useImage hook gives you more control on when and how to render the preloaded image (ex: use the image source as background-image)

import { useImage } from 'react-imgp';

const imageProps = {
  src: 'https://dummyimage.com/600x400/000/fff',
};

const App = () => {
  const { loaded } = useImage(imageProps);

  return loaded ? (
    <div
      style={{
        backgroundImage: `url(imageProps.src)`
      }}
    />
  ) : null;
};

Install

  • npm install react-imgp

Dependencies

  • The following are not bundled :

    • Promise API
    • Peer dependency react >= 17.0.x

Author

Keywords

FAQs

Package last updated on 23 Sep 2021

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