
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-load-image
Advanced tools
A React component for showing placeholder content during image loading
This is a fork of https://github.com/hzdg/react-imageloader, however many design changes were made and deprecations fixed so it warranted its own repo/package.
This React component allows you to display content while waiting for the image to load, as well as by showing alternate content if the image fails to load.
npm install react-load-image
import React from 'react';
import ImageLoader from 'react-load-image';
function Preloader(props) {
return <img src="spinner.gif" />;
}
React.render((
<ImageLoader
src="/path/to/image.jpg"
>
<img />
<div>Error!</div>
<Preloader />
</ImageLoader>
), document.body);
| Name | Type | Description |
|---|---|---|
onError | function | An optional handler for the [error] event. |
onLoad | function | An optional handler for the [load] event. |
src | string | The URL of the image to be loaded, will be passed as the src prop to your first child provided. If you want to use it as a background image, make your first child a react component like Name = (props) => <div style={{backgroundImage: props.src}}/> and do |
srcSet | string | An optional value for the srcset attribute of the img |
The first child of ImageLoader will be rendered when the image is successfully loaded. The src prop will be passed to it.
The second child of ImageLoader will be rendered when the image load fails.
The third child of ImageLoader will be rendered when the image is in the process of loading
import React from 'react';
import ImageLoader from 'react-load-image';
import ImageError from './ImageError';
import ImageLoading from './ImageLoading';
const Image = (props) =>
<ImageLoader {...props}>
{this.props.children[0]}
<ImageError />
<ImageLoader />
</ImageLoader>
export default Image;
import Image from './Image';
...
<Image style={{width: '50px'}}>
<img style={{border: none}} />
</Image>
...
import React from 'react';
const BackgroundImage = ({src, style = {}, ...props} = {}) =>
<div style={Object.assign({backgroundImage: `url(${src})`}, style)} {...props} />
export default BackgroundImage;
<Image style={{width: '50px'}}>
<BackgroundImage />
</Image>
FAQs
A React component for showing placeholder content during image loading
The npm package react-load-image receives a total of 2,936 weekly downloads. As such, react-load-image popularity was classified as popular.
We found that react-load-image 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.