twobin / react-lazyload

Lazy load your component, image or anything matters the performance.
MIT License
5.85k stars 487 forks source link

react-lazyload is not working on divs. #318

Closed aditya-padhi-kbl closed 4 years ago

aditya-padhi-kbl commented 4 years ago

Hi Team,

I would like to thank you for this great library. However I am facing an issue with the implementation. The url is:- https://codesandbox.io/s/sample-poc-on-react-lazyload-p996u

I am rendering 100 divs each wrapped in LazyLoad component but when I inspect the DOM I see that the component is still rendered even though it is not in the viewport. Please let me me know in case I am missing something in the implementation

cooskun commented 4 years ago

I have inspected your code and it seems like react-lazyload doesn't work without height props. If you put height it will be working. But having the possibility to use it with dynamic height.

https://codesandbox.io/s/sample-poc-on-react-lazyload-zvtiv

aditya-padhi-kbl commented 4 years ago

Thank-you @cooskun I was not aware of the height prop as it was not mentioned in the documentation.