1.0.0 • Published 6 years ago

preload-component v1.0.0

Weekly downloads
9
License
-
Repository
github
Last release
6 years ago

preload-component

Travis npm package Coveralls

Preload images the react way

Install

$ npm install preload-component --save

Usage

import Preload from 'preload-component'

..

render () {
  return (
    <Preload
      images={[img1, img2]}
      onLoad={() => console.log('images loaded!')}
    >
      {hasLoaded => hasLoaded ? <Fragment><img src={img1} /> <img src={img2} /></Fragment> : null}
    </Preload>
  )
}

API

ParamTypefunctionalityrequired
imagesArrayArray of urls you want to preloadtrue
childrenFunctionrender function taking the image array load statetrue
onLoadFunctionNotify consuming component when images are loadedfalse

License

MIT © Jack Hanford