DEV Community

Discussion on: Intersection Observer using React

Collapse
 
m3rtzi profile image
Jakob Lilliemarck

Thanks for a great article/tutorial - it helped me alot in implementing lazy-loading of content based on visibility in a React project.

In doing so, however, it seems calling observer.unobserve(target) in the cleanup is not enough - react complains about calling setState on unmounted component. calling observer.disconnect() seem to unregister the IntersectionObserver completely and made React stop complaining.