5
5
> Lazy load your content without breaking the internet!
6
6
7
7
Supports universal rendering including disabled JavaScript by using ` noscript ` elements that are also friendly to all
8
- search engines. Uses modern IntersectionObserver API and exposes ` Observer ` component which works exactly like the
9
- excellent [ @researchgate/react-intersection-observer ] ( https://github.com/researchgate/react-intersection-observer ) , but
10
- with a few minor changes.
8
+ search engines. Uses modern IntersectionObserver API using the excellent
9
+ [ @researchgate/react-intersection-observer ] ( https://github.com/researchgate/react-intersection-observer ) .
11
10
12
11
Also optionally supports displaying the content on IE8 and earlier by adding conditional comments to skip ` noscript `
13
12
elements.
@@ -20,22 +19,20 @@ npm install react-lazy
20
19
import { Lazy } from ' react-lazy'
21
20
// or
22
21
import { LazyGroup } from ' react-lazy'
23
- // or
24
- import { Observer } from ' react-lazy'
25
22
```
26
23
27
24
You also need to polyfill ` intersection-observer ` ! Use polyfill.io or ` require('intersection-observer') ` . Check
28
- [ Can I use] ( https://caniuse.com/#feat=intersectionobserver ) for browser support status. Additionally features like ` Map `
29
- and ` Set ` are also required.
25
+ [ Can I use] ( https://caniuse.com/#feat=intersectionobserver ) for browser support status. ` Map ` and ` Set ` are also
26
+ required, but these are required by React as well .
30
27
31
28
32
29
----
33
30
34
31
## Why ` react-lazy ` ?
35
32
36
33
1 . Minimalistic and performant implementation with less dependencies than other solutions
37
- 2 . You can choose between ease-of-use (LazyGroup) and do-it-yourself (Lazy, Observer )
38
- 3 . The hard part of handling ` noscript ` is done for you (Lazy, LazyGroup)
34
+ 2 . You can choose between ease-of-use (LazyGroup) and do-it-yourself (Lazy)
35
+ 3 . The hard part of handling ` noscript ` is done for you
39
36
40
37
41
38
----
@@ -92,21 +89,7 @@ import { Lazy } from 'react-lazy'
92
89
93
90
## Component introduction
94
91
95
- First of all, ` Observer ` component is exposed. This is a powerful component for using the new IntersectionObserver API.
96
- The notable differences to the implementation of
97
- [ @researchgate/react-intersection-observer ] ( https://github.com/researchgate/react-intersection-observer ) are:
98
-
99
- - ` viewport ` prop is added and preferred over ` root ` prop
100
- - ` cushion ` prop is added and preferred over ` rootMargin ` prop
101
- - ` onlyOnce ` prop deprecation has been enforced and is unsupported
102
- - Other changes are internal code optimizations for further minor speed improvements and reduced code size
103
-
104
- Essentially ` react-lazy ` 's implementation of ` <Observer /> ` is fully compatible with all the examples and demos you find
105
- at [ @researchgate/react-intersection-observer ] ( https://github.com/researchgate/react-intersection-observer ) . (This part
106
- of the text holds true in 2018-05-30 at version 0.7.1 - throw issue if this state changes).
107
-
108
-
109
- As for lazy loading there are two components: ` <Lazy /> ` and ` <LazyGroup /> ` .
92
+ There are two components: ` <Lazy /> ` and ` <LazyGroup /> ` .
110
93
111
94
** Lazy** provides basic functionality for lazy loading: it keeps render in ` noscript ` element until it has come into
112
95
viewport and then simply swaps render. ** Everything** inside the component is wrapped into ` noscript ` . As the component
0 commit comments