'use client'; import { useState, useEffect, useRef } from "react"; import parse from 'html-react-parser'; export default function ProductDescription( {name, description}:any ) { const contentRef = useRef(null); const containerRef = useRef(null); const [isOverflow, setIsOverflow] = useState(false); const [expanded, setExpanded] = useState(false); useEffect(() => { if (contentRef.current) { if (contentRef.current.scrollHeight > 700) { setIsOverflow(true); } } }, [description]); const handleCollapse = () => { setExpanded(false); containerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start', }); }; return (

Đánh giá {name}

{parse(description)}
{isOverflow && (
{!expanded ? ( ) : ( )}
)}
) }