You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 19, 2022. It is now read-only.
Copy file name to clipboardexpand all lines: README.md
+43-27
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,11 @@
5
5
6
6
[`react-progressive-image`](https://www.npmjs.com/package/react-progressive-image) React component for progressive image loading
7
7
8
-
## Installation
9
-
10
-
Using [npm](https://www.npmjs.com/):
11
-
12
-
$ npm install --save react-progressive-image
8
+
### Install
13
9
10
+
```bash
11
+
$ yarn add react-progressive-image
12
+
```
14
13
15
14
The UMD build is also available on [unpkg](https://unpkg.com):
16
15
@@ -20,50 +19,67 @@ The UMD build is also available on [unpkg](https://unpkg.com):
20
19
21
20
If you use the UMD build you can find the library on `window.ReactProgressiveImage`.
22
21
23
-
##Usage
22
+
### Examples
24
23
25
-
`react-progressive-image` exports a single React component, `ProgressiveImage`, which takes a `src` and `placeholder` prop, as well as optional props `srcSetData`, and `onError` function.
24
+
#### Simple
26
25
27
-
`src` should be the final image you want to load, and `placeholder` is the image you want to display until `src` is loaded. `placeholder` can be anything you want. A typical use case might involve using a smaller version of the image, an inlined version (data URI), or a loading graphic.
28
-
29
-
If you would like to supply a srcSet for the image, you can use the `srcSetData` prop. The prop should be and object containing two properties, `srcSet`, and `sizes`.
`ProgressiveImage` accepts a render callback as a child, which will be called with the `placeholder` first, and then `src` once the image has been loaded.
It will also call the render callback with a second argument, `loading`, which you can use to quickly determine what image is being rendered. `loading` will be `true` when the placeholder is rendered, and `false` when the full image is rendered.
If the `srcSetData` prop is supplied, it will be returned as the third argument to the render callback. This is helpful if you are sharing a render function between multiple different `ProgressiveImage` components.
0 commit comments