import { FC, useEffect, useRef, useState } from 'react'; import Pop from '../pop'; interface ITreeContentProps { showPop?: boolean; } export const TreeContent: FC = ({ children, showPop }) => { const contentRef = useRef(null); const [isOverflowing, setIsOverflowing] = useState(false); const [popVisible, setPopVisible] = useState(false); useEffect(() => { if (!contentRef.current) return; const { scrollWidth, clientWidth } = contentRef.current; setIsOverflowing(scrollWidth > clientWidth); }, [contentRef]); return ( setPopVisible(visible)} trigger={showPop && isOverflowing ? 'hover' : 'none'} > {children} ); };