"use client"; import { HTMLAttributes, useEffect, useRef } from "react"; import data from "@/components/app/(home)/sections/hero-flame/data.json"; import { cn } from "@/utils/cn"; import { setIntervalOnVisible } from "@/utils/set-timeout-on-visible"; export default function StoriesFlame(attrs: HTMLAttributes) { const ref = useRef(null); const wrapperRef = useRef(null); useEffect(() => { let index = 0; const interval = setIntervalOnVisible({ element: wrapperRef.current, callback: () => { index++; if (index >= data.length) index = 0; const newStr = data[index]; if (!ref.current) return; ref.current!.innerHTML = newStr; }, interval: 60, }); return () => interval?.(); }, []); return (
); }