React component for progressive image loading
React component for progressive image loading
react-progressive-image React component for progressive image loading
$ yarn add react-progressive-imageThe UMD build is also available on unpkg:
If you use the UMD build you can find the library on window.ReactProgressiveImage.
{src => }
{src => }
{(src, loading) => (
)}
{(src, _loading, srcSetData) => (
)}
If you want to use a component, such as a loading spinner, as a placeholder, you can make use of the loading argument in the render callback. It will be true while the main image is loading and false once it has fully loaded. Keep in mind that the placeholder props is required, so you will need to explicitly declare an empty string as it's value if you plan on using a component in the render callback.
const dominantImageColor = '#86356B';
const placeholder = (
);
}}
| Name | Type | Required | Description |
|---|---|---|---|
| children | function |
true |
returns src, loading, and srcSetData |
| delay | number |
false |
time in milliseconds before src image is loaded |
| onError | function |
false |
returns error event |
| placeholder | string |
true |
the src of the placeholder image |
| src | string |
true |
the src of the main image |
| srcSetData | {srcSet: "string", sizes: "string" } |
false |
srcset and sizes to be applied to the image |
Archived: This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!
No open issues yet, or sync has not completed.