let preloadImagesData = [
// 'img/game/main-img-x2.png',
// '/img/game/items-list-bg.svg',
// '/img/game/loader-cat-white.png',
// '/img/game/title-img.svg',
// '/img/game/tree.svg',
// '/img/game/main-cat-home.svg',
// '/img/game/main-screen-bg.svg'
]
useEffect(() => {
const cacheImages = async (srcArray) => {
const promises = srcArray.map((item) => {
return new Promise((resolve, reject) => {
const img = new Image();
img.src = item;
img.onload = resolve;
img.onerror = reject;
});
});
await Promise.all(promises);
setIsImagePreloading(false);
};
cacheImages(preloadImagesData);
}, []);