"use client"; import { useEffect, useState } from "react"; import { Heading } from "./heading"; import { Subheading } from "./subheading"; import Image from "next/image"; import { AnimatePresence, motion } from "framer-motion"; export const Companies = () => { let [logos, setLogos] = useState([ [ { title: "netflix", src: "/logos/netflix.png", }, { title: "google", src: "/logos/google.webp", }, { title: "meta", src: "/logos/meta.png", }, { title: "onlyfans", src: "/logos/onlyfans.png", }, ], [ { title: "netflix second", src: "/logos/netflix.png", }, { title: "google second", src: "/logos/google.webp", }, { title: "meta second", src: "/logos/meta.png", }, { title: "onlyfans second", src: "/logos/onlyfans.png", }, ], ]); const [activeLogoSet, setActiveLogoSet] = useState(logos[0]); const [isAnimating, setIsAnimating] = useState(false); const flipLogos = () => { setLogos((currentLogos) => { const newLogos = [...currentLogos.slice(1), currentLogos[0]]; setActiveLogoSet(newLogos[0]); setIsAnimating(true); return newLogos; }); }; useEffect(() => { if (!isAnimating) { const timer = setTimeout(() => { flipLogos(); }, 3000); return () => clearTimeout(timer); // Clear timeout if component unmounts or isAnimating changes } }, [isAnimating]); return (
Trusted by the best companies [App Name] is trusted by leading companies worldwide.
{ setIsAnimating(false); }} > {activeLogoSet.map((logo, idx) => ( {logo.title} ))}
); };