twobin / react-lazyload

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

trigger function when component comes into view #332

Closed adventmedia closed 3 years ago

adventmedia commented 3 years ago

I want to be able to trigger a function through a callback or whatever, specifically to call an API to load more chat messages… according to https://github.com/twobin/react-lazyload/pull/65 this can be triggered within the component by using componentDidRender, but with current React being functional, this isn't available - but useEffect is not handling this either. In any case I would want to call the API in the parent component so a callback prop (or an event) would be useful. Can't use react-lazyload as it is.

adventmedia commented 3 years ago

its more complicated… LazyLoading loading a number of components that are outside of the viewport - not all, but more than are visible.