From fe8fbf3024796a5da190dfdded98565c7c29c841 Mon Sep 17 00:00:00 2001 From: Rene Arumetsa Date: Thu, 30 Apr 2026 16:28:19 +0300 Subject: [PATCH] Carosel slide every 5s --- src/components/TeaserCarousel.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 (
@@ -58,7 +63,7 @@ export default function TeaserCarousel() {
-

+

{t("heading")}