import * as React from 'react'; import { useRef } from 'react'; import { composeRef } from 'rc-util/lib/ref'; import raf from 'rc-util/lib/raf'; import Tooltip, { TooltipProps } from '../tooltip'; const SliderTooltip = React.forwardRef((props, ref) => { const { visible } = props; const innerRef = useRef(null); const rafRef = useRef(null); function cancelKeepAlign() { raf.cancel(rafRef.current!); rafRef.current = null; } function keepAlign() { rafRef.current = raf(() => { innerRef.current?.forcePopupAlign(); rafRef.current = null; }); } React.useEffect(() => { if (visible) { keepAlign(); } else { cancelKeepAlign(); } return cancelKeepAlign; }, [visible, props.title]); return ; }); export default SliderTooltip;