diff --git a/src/components/TeaserCarousel.tsx b/src/components/TeaserCarousel.tsx index a42a601..bacd63e 100644 --- a/src/components/TeaserCarousel.tsx +++ b/src/components/TeaserCarousel.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState } from "react"; +import { useState, useEffect, useCallback } from "react"; import Image from "next/image"; import { Link } from "@/i18n/routing"; import { vipnagorgialla } from "@/components/Vipnagorgialla"; @@ -26,8 +26,13 @@ export default function TeaserCarousel() { const t = useTranslations("home.teaser"); const [current, setCurrent] = useState(0); + const next = useCallback(() => setCurrent((c) => (c + 1) % slides.length), []); const prev = () => setCurrent((c) => (c - 1 + slides.length) % slides.length); - const next = () => setCurrent((c) => (c + 1) % slides.length); + + useEffect(() => { + const id = setInterval(next, 5000); + return () => clearInterval(id); + }, [next]); return (