diff --git a/src/sections/Home/Partners-home/index.js b/src/sections/Home/Partners-home/index.js index 70ac4fac3b7e..f1902001e916 100644 --- a/src/sections/Home/Partners-home/index.js +++ b/src/sections/Home/Partners-home/index.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { memo, Suspense, useState, useEffect } from "react"; import { Container, Row } from "../../../reusecore/Layout"; import SectionTitle from "../../../reusecore/SectionTitle"; import PartnerItemWrapper from "./partnerSection.style"; @@ -8,8 +8,8 @@ import Slider from "react-slick"; import "slick-carousel/slick/slick.css"; import "slick-carousel/slick/slick-theme.css"; -const PartnerImage = ({ partner }) => ( -
+const PartnerImage = memo(({ partner }) => ( +
( alt={partner.name} width={partner.imageWidth} height={partner.imageHeight} + loading="eager" />
+)); + +const PartnerSlider = memo(({ settings, isVisible }) => ( +
+ + {partners.map((partner, index) => ( + + + + ))} + +
+)); + +const SliderFallback = () => ( +
); const Projects = () => { - const [imagesLoaded, setImagesLoaded] = useState(false); + const [isLoaded, setIsLoaded] = useState(false); useEffect(() => { - const imagePromises = partners.map(partner => { - return new Promise((resolve, reject) => { - const img = new Image(); - img.onload = resolve; - img.onerror = reject; - img.src = partner.imageLink; - }); - }); - - Promise.all(imagePromises) - .then(() => setImagesLoaded(true)) - .catch(error => console.error("Error preloading images:", error)); + const timer = setTimeout(() => { + setIsLoaded(true); + }, 300); + return () => clearTimeout(timer); }, []); const settings = { @@ -48,7 +64,7 @@ const Projects = () => { speed: 500, centerMode: true, variableWidth: true, - autoplay: true, + autoplay: isLoaded, autoplaySpeed: 1500, className: "partner-slider", responsive: [ @@ -72,19 +88,14 @@ const Projects = () => { - {imagesLoaded ? ( - - {partners.map((partner, index) => ( - - - - ))} - - ) : ( -
Loading partners...
- )} + }> + + ); }; -export default Projects; +export default Projects; \ No newline at end of file