import React, { useRef, useState, useEffect } from 'react'; import './MarqueeText.css'; const MarqueeText = ({ text, className, style, duration = '10s' }) => { const containerRef = useRef(null); const textRef = useRef(null); const [isOverflowing, setIsOverflowing] = useState(false); const formattedDuration = typeof duration === 'number' ? `${duration}s` : duration; useEffect(() => { const checkOverflow = () => { if (containerRef.current && textRef.current) { setIsOverflowing(textRef.current.scrollWidth > containerRef.current.clientWidth); } }; checkOverflow(); window.addEventListener('resize', checkOverflow); return () => window.removeEventListener('resize', checkOverflow); }, [text]); return (