Created
November 16, 2020 08:22
-
-
Save mkhoussid/d6a1a7b3d029c42bbcb45bdc929602c8 to your computer and use it in GitHub Desktop.
PreloadImages component (download images before DOM has loaded)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This preloads images BEFORE DOM has loaded | |
// See usePreloadImages.ts for loading images after DOM has loaded (https://gist.github.com/mkhoussid/c960ba200d6ef9142b80769a7c84e5f1) | |
import React from 'react'; | |
type TPreloadImages = { | |
imageUrls: string[]; | |
}; | |
export default React.memo(({ imageUrls }: TPreloadImages) => { | |
return ( | |
<div style={{ display: 'none' }}> | |
{imageUrls.map((imageUrl) => ( | |
<img src={imageUrl} /> | |
))} | |
</div> | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment