MCPcopy Create free account
hub / github.com/react-component/tooltip / Tooltip

Function Tooltip

src/Tooltip.tsx:66–156  ·  view source on GitHub ↗
(props: TooltipProps, ref: React.Ref<TooltipRef>)

Source from the content-addressed store, hash-verified

64export interface TooltipRef extends TriggerRef { }
65
66const Tooltip = (props: TooltipProps, ref: React.Ref<TooltipRef>) => {
67 const {
68 overlayClassName,
69 trigger = ['hover'],
70 mouseEnterDelay = 0,
71 mouseLeaveDelay = 0.1,
72 overlayStyle,
73 prefixCls = 'rc-tooltip',
74 children,
75 onVisibleChange,
76 afterVisibleChange,
77 transitionName,
78 animation,
79 motion,
80 placement = 'right',
81 align = {},
82 destroyTooltipOnHide = false,
83 defaultVisible,
84 getTooltipContainer,
85 overlayInnerStyle,
86 arrowContent,
87 overlay,
88 id,
89 showArrow = true,
90 classNames: tooltipClassNames,
91 styles: tooltipStyles,
92 ...restProps
93 } = props;
94
95 const mergedId = useId(id);
96 const triggerRef = useRef<TriggerRef>(null);
97
98 useImperativeHandle(ref, () => triggerRef.current);
99
100 const extraProps: Partial<TooltipProps & TriggerProps> = { ...restProps };
101 if ('visible' in props) {
102 extraProps.popupVisible = props.visible;
103 }
104
105 const getPopupElement = () => (
106 <Popup
107 key="content"
108 prefixCls={prefixCls}
109 id={mergedId}
110 bodyClassName={tooltipClassNames?.body}
111 overlayInnerStyle={{ ...overlayInnerStyle, ...tooltipStyles?.body }}
112 >
113 {overlay}
114 </Popup>
115 );
116
117 const getChildren = () => {
118 const child = React.Children.only(children);
119 const originalProps = child?.props || {};
120
121 const childProps = {
122 ...originalProps,
123 'aria-describedby': overlay ? mergedId : null,

Callers

nothing calls this directly

Calls 1

getChildrenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…