-
-
Notifications
You must be signed in to change notification settings - Fork 529
Expand file tree
/
Copy pathTooltipWrapper.tsx
More file actions
55 lines (51 loc) · 1.27 KB
/
TooltipWrapper.tsx
File metadata and controls
55 lines (51 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { useEffect, useRef } from 'react'
import clsx from 'clsx'
import { useTooltip } from './TooltipProvider'
import type { ITooltipWrapper } from './TooltipProviderTypes'
/**
* @deprecated Use the `data-tooltip-id` attribute, or the `anchorSelect` prop instead.
* See https://react-tooltip.com/docs/getting-started
*/
const TooltipWrapper = ({
tooltipId,
children,
className,
place,
content,
html,
variant,
offset,
wrapper,
events,
positionStrategy,
delayShow,
delayHide,
}: ITooltipWrapper) => {
const { attach, detach } = useTooltip(tooltipId)
const anchorRef = useRef<HTMLElement | null>(null)
useEffect(() => {
attach(anchorRef)
return () => {
detach(anchorRef)
}
}, [])
return (
<span
ref={anchorRef}
className={clsx('react-tooltip-wrapper', className)}
data-tooltip-place={place}
data-tooltip-content={content}
data-tooltip-html={html}
data-tooltip-variant={variant}
data-tooltip-offset={offset}
data-tooltip-wrapper={wrapper}
data-tooltip-events={events}
data-tooltip-position-strategy={positionStrategy}
data-tooltip-delay-show={delayShow}
data-tooltip-delay-hide={delayHide}
>
{children}
</span>
)
}
export default TooltipWrapper