Aljullu / react-lazy-load-image-component

React Component to lazy load images and components using a HOC to track window scroll position.
https://www.npmjs.com/package/react-lazy-load-image-component
MIT License
1.46k stars 110 forks source link

Images keep loading even image is not part of the DOM anymore (Switching pages/views) #117

Open rkkoszewski opened 1 year ago

rkkoszewski commented 1 year ago

Bug description I'm using react-lazy-load-image-component. I have several bigger images that are loading and it can take several seconds for it to finish downloading. When I click on a link while an image is loading, the image keeps downloading in the background while the image element is not part of the DOM anymore.

I'd expect the loading of the image to be cancelled when the image element is removed from the DOM.

To Reproduce Create a lazy loaded image element, and a link that just removes that image element. Throttle the download speed and remove the image element while it's loading, and see that in the web browser network view you can still see the image downloading.

Technical details: