Skip to content

Commit eb23ffc

Browse files
committed
chore: fix missing def
1 parent 13b7b90 commit eb23ffc

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Tooltip.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { TriggerProps } from '@rc-component/trigger';
1+
import type { TriggerProps, TriggerRef } from '@rc-component/trigger';
22
import Trigger from '@rc-component/trigger';
33
import type { ActionType, AlignType, AnimationType } from '@rc-component/trigger/lib/interface';
44
import * as React from 'react';
@@ -37,7 +37,11 @@ export interface TooltipProps extends Pick<TriggerProps, 'onPopupAlign' | 'built
3737
zIndex?: number;
3838
}
3939

40-
const Tooltip = (props: TooltipProps, ref) => {
40+
export interface TooltipRef {
41+
forceAlign: VoidFunction;
42+
}
43+
44+
const Tooltip = (props: TooltipProps, ref: React.Ref<TooltipRef>) => {
4145
const {
4246
overlayClassName,
4347
trigger = ['hover'],
@@ -64,8 +68,8 @@ const Tooltip = (props: TooltipProps, ref) => {
6468
...restProps
6569
} = props;
6670

67-
const domRef = useRef(null);
68-
useImperativeHandle(ref, () => domRef.current);
71+
const triggerRef = useRef<TriggerRef>(null);
72+
useImperativeHandle(ref, () => triggerRef.current);
6973

7074
const extraProps = { ...restProps };
7175
if ('visible' in props) {
@@ -86,7 +90,7 @@ const Tooltip = (props: TooltipProps, ref) => {
8690
action={trigger}
8791
builtinPlacements={placements}
8892
popupPlacement={placement}
89-
ref={domRef}
93+
ref={triggerRef}
9094
popupAlign={align}
9195
getPopupContainer={getTooltipContainer}
9296
onPopupVisibleChange={onVisibleChange}

0 commit comments

Comments
 (0)