loktar00 / react-lazy-load

React component that renders children elements when they enter the viewport.
MIT License
979 stars 166 forks source link

"Connected" lazyload loads simultaneously #173

Open eneadriancatalin opened 4 months ago

eneadriancatalin commented 4 months ago

If you have 2 lazyload each one next to the other, when the first one is in viewpost, the second one is loaded automatically. Example:

<div>
<LazyLoad ..>
    <Component1 />
  </LazyLoad>
</div>
<div>
  <LazyLoad ..>
    <Component2 />
  </LazyLoad>
</div>

Even if I have the inside a div, when the Component1 is in the viewport, the Component2 is loaded too

Workaround: If you have some content between each then it loads when it is the viewport

<LazyLoad ..>
  <Component1 />
</LazyLoad>
<div>Filler content</div>
<LazyLoad ..>
  <Component2 />
</LazyLoad>
<div>Some more spacer content</div>

Now Conmponent1 is loaded when it's in the viewport, and Component2 is loaded when it's in the viewport

loktar00 commented 4 months ago

Not sure I understand, looks like your code wasn't fully added to the issue.