1- import type { TriggerProps } from '@rc-component/trigger' ;
1+ import type { TriggerProps , TriggerRef } from '@rc-component/trigger' ;
22import Trigger from '@rc-component/trigger' ;
33import type {
44 ActionType ,
@@ -7,7 +7,7 @@ import type {
77 BuildInPlacements ,
88} from '@rc-component/trigger/lib/interface' ;
99import classNames from 'classnames' ;
10- import { composeRef , getNodeRef , supportRef } from 'rc-util/lib/ref' ;
10+ import { composeRef , getNodeRef , supportRef } from '@ rc-component/ util/lib/ref' ;
1111import React from 'react' ;
1212import useAccessibility from './hooks/useAccessibility' ;
1313import Overlay from './Overlay' ;
@@ -46,7 +46,10 @@ export interface DropdownProps
4646 autoFocus ?: boolean ;
4747}
4848
49- function Dropdown ( props : DropdownProps , ref ) {
49+ const Dropdown : React . ForwardRefRenderFunction < TriggerRef , DropdownProps > = (
50+ props ,
51+ ref ,
52+ ) => {
5053 const {
5154 arrow = false ,
5255 prefixCls = 'rc-dropdown' ,
@@ -72,9 +75,10 @@ function Dropdown(props: DropdownProps, ref) {
7275 const [ triggerVisible , setTriggerVisible ] = React . useState < boolean > ( ) ;
7376 const mergedVisible = 'visible' in props ? visible : triggerVisible ;
7477
75- const triggerRef = React . useRef ( null ) ;
76- const overlayRef = React . useRef ( null ) ;
77- const childRef = React . useRef ( null ) ;
78+ const triggerRef = React . useRef < TriggerRef > ( null ) ;
79+ const overlayRef = React . useRef < HTMLElement > ( null ) ;
80+ const childRef = React . useRef < HTMLElement > ( null ) ;
81+
7882 React . useImperativeHandle ( ref , ( ) => triggerRef . current ) ;
7983
8084 const handleVisibleChange = ( newVisible : boolean ) => {
@@ -174,6 +178,6 @@ function Dropdown(props: DropdownProps, ref) {
174178 { childrenNode }
175179 </ Trigger >
176180 ) ;
177- }
181+ } ;
178182
179183export default React . forwardRef ( Dropdown ) ;
0 commit comments