Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
react-lazy-load-image-observer
Advanced tools
The LazyLoadImage component allows you to lazy load images, or background-images, and set the observed element.
The LazyLoadImage component allows you to lazy load images, or background-images, and set the observed element.
yarn add react-lazy-load-image
or
npm install react-lazy-load-image
import LazyLoadImage from 'react-lazy-load-image'
The wrapperRef
declares the element you want to observer to trigger the image loading.
Use imageRef
if you want to load an image to an <img>
element.
Use backgroundRef
if you want to load an image to an element's background-image
.
If you omit wrapperRef
, the observed elem will be imageRef
. You can omit backgroundRef
as well.
prop | desc |
---|---|
imageSrc | src of the image, string |
classAdded | name of class added to the observed element once the image has loaded, default is loaded |
In order to animate, you'll have to add css in in regards to the .loaded
class.
Something like
opacity: 0;
transition: opacity 400ms ease-in-out;
&.loaded {
opacity: 1;
}
OR if using a wrapperRef
, then
opacity: 0;
transition: opacity 400ms ease-in-out;
& .loaded {
opacity: 1;
}
^^ notice the space in & .loaded
, versus &.loaded
<LazyLoadImage imageSrc={src}>
{({ wrapperRef, imageRef, backgroundRef }) => (
<span ref={wrapperRef}>
<img ref={imageRef} />
<span ref={backgroundRef} />
</span>
)}
</LazyLoadImage>
<LazyLoadImage imageSrc={src}>{({ imageRef }) => <img ref={imageRef} />}</LazyLoadImage>
<LazyLoadImage imageSrc={src}>
{({ backgroundRef }) => (
<div>
<div ref={backgroundRef} />
</div>
)}
</LazyLoadImage>
FAQs
The LazyLoadImage component allows you to lazy load images, or background-images, and set the observed element.
The npm package react-lazy-load-image-observer receives a total of 3 weekly downloads. As such, react-lazy-load-image-observer popularity was classified as not popular.
We found that react-lazy-load-image-observer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.