sambernard / react-preload

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

cache overflow and ready prop features #6

Open krukid opened 8 years ago

krukid commented 8 years ago

Hi, the component looks nice, unfortunately I cannot use it as is for my use case, which is:

SPA that shows pages of images, preloading the next page until the user forces it to show.

This can be supported by adding two features:

  1. Pass a ready prop that would override internal state and show the children, which would allow an external event like user interaction to affect things regardless of preload status.
  2. Specify max cache size that would ensure older images get dropped from the cache.

I can work around the "ready prop" by doing something like:

render() {
  const {ready, children, ...other} = this.props
  return (
    {ready ? <Preload {...other}>{children}</Preload> : {children}}
  )
}

But seems that encapsulating this may be cleaner.