sambernard / react-preload

Component to preload images before showing content
MIT License
148 stars 48 forks source link

images not preloading on receiving new props #12

Closed thetechnaddict closed 6 years ago

thetechnaddict commented 8 years ago

the component has provided a brautifully simple means of preloading a series of images on a slide show for an artists site I am developing, thank you.

The issue is that images are preloaded once only even if the component is sent a new lot of images.

For example, given a single gallery component that presents different sets of images (paintings and sculptures in this instance) when the user first clicks on paintings it pre-loads the paintings and all is well - when the user then clicks on sculptures (without returning to the home page first) no pre-loading occurs.

I believe this is because the preload component does its preloading on componentWillMount - in the containing component that passes the images I also reload data on componentWillReceiveProps to effect the switch between galleries.

Being inexperienced I am hesitent of creating a pull request before asking if this seems like a good approach for this component.

thetechnaddict commented 8 years ago

I see that Mathias Wolff's fork (xymw) deals with this nicely.

ariesjia commented 8 years ago

+1 for this

madshargreave commented 7 years ago

+1

Tailzip commented 6 years ago

+1

sambernard commented 6 years ago

Fixe in https://github.com/sambernard/react-preload/commit/eba034fd1ccd1ec599170970f57d67e61688cde1