import { cn } from '@/components/ui/core/styling'; import { motion, stagger, useAnimate } from 'framer-motion'; import React, { useEffect } from 'react'; export const TextGenerateEffect = ({ words, className, style, ...rest }: { words: string; className?: string; style?: any; } & React.HTMLAttributes) => { const [scope, animate] = useAnimate(); let wordsArray = words.split(' '); useEffect(() => { animate( 'span', { opacity: 1, }, { duration: 2, delay: stagger(0.2), } ); }, [words]); const renderWords = () => { return ( {wordsArray.map((word, idx) => { return ( {word}{' '} ); })} ); }; return (
{renderWords()}
); };