Skip to content

Commit f790337

Browse files
committed
refactor(layout): remove forwardRef and clean up imports
1 parent 8342f7a commit f790337

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

packages/layout/src/components/TooltipWrapper/TooltipWrapper.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1+
import type { TooltipProps } from '@rocket.chat/fuselage';
12
import {
23
AnimatedVisibility,
34
PositionAnimated,
45
Tooltip,
56
} from '@rocket.chat/fuselage';
67
import { useDebouncedState } from '@rocket.chat/fuselage-hooks';
78
import type {
8-
ComponentProps,
99
Dispatch,
1010
RefObject,
1111
ReactElement,
1212
ReactNode,
13-
Ref,
1413
SetStateAction,
14+
RefAttributes,
1515
} from 'react';
16-
import {
17-
cloneElement,
18-
forwardRef,
19-
useCallback,
20-
useId,
21-
useMemo,
22-
useRef,
23-
} from 'react';
16+
import { cloneElement, useCallback, useId, useMemo, useRef } from 'react';
2417

2518
export type AnchorParams = {
2619
ref: RefObject<Element | null>;
@@ -46,17 +39,17 @@ const getAnchor = (
4639
});
4740
};
4841

42+
type InnerTooltipProps = Omit<TooltipProps, 'ref'> &
43+
RefAttributes<HTMLDivElement>;
44+
4945
// Workaround to the c̶r̶a̶p̶p̶y̶ not-so-great API of PositionAnimated
50-
const InnerTooltip = forwardRef(function InnerTooltip(
51-
{ style, ...props }: ComponentProps<typeof Tooltip>,
52-
ref: Ref<HTMLDivElement>,
53-
) {
46+
function InnerTooltip({ ref, style, ...props }: InnerTooltipProps) {
5447
return (
5548
<div ref={ref} style={style}>
5649
<Tooltip {...props} />
5750
</div>
5851
);
59-
});
52+
}
6053

6154
export type TooltipWrapperProps = {
6255
children: ReactElement<any> | ((props: AnchorParams) => ReactNode);

0 commit comments

Comments
 (0)