react-tooltip 5.0.0-beta.1 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -1
- package/CODE_OF_CONDUCT.md +53 -0
- package/LICENSE +1 -2
- package/README.md +30 -152
- package/coverage/clover.xml +610 -0
- package/coverage/coverage-final.json +11 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/components/Tooltip/Tooltip.tsx.html +646 -0
- package/coverage/lcov-report/components/Tooltip/index.html +146 -0
- package/coverage/lcov-report/components/Tooltip/index.ts.html +88 -0
- package/coverage/lcov-report/components/Tooltip/styles.module.css.html +277 -0
- package/coverage/lcov-report/components/TooltipContent/TooltipContent.tsx.html +109 -0
- package/coverage/lcov-report/components/TooltipContent/index.html +131 -0
- package/coverage/lcov-report/components/TooltipContent/index.ts.html +88 -0
- package/coverage/lcov-report/components/TooltipController/TooltipController.tsx.html +664 -0
- package/coverage/lcov-report/components/TooltipController/constants.ts.html +118 -0
- package/coverage/lcov-report/components/TooltipController/index.html +146 -0
- package/coverage/lcov-report/components/TooltipController/index.ts.html +88 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/sum.js.html +97 -0
- package/coverage/lcov-report/sum.ts.html +100 -0
- package/coverage/lcov-report/test/index.html +116 -0
- package/coverage/lcov-report/test/sum.ts.html +100 -0
- package/coverage/lcov-report/utils/compute-positions.ts.html +277 -0
- package/coverage/lcov-report/utils/debounce.ts.html +181 -0
- package/coverage/lcov-report/utils/index.html +131 -0
- package/coverage/lcov.info +729 -0
- package/dist/react-tooltip.cjs.js +3 -6
- package/dist/react-tooltip.cjs.min.js +1 -1
- package/dist/react-tooltip.esm.js +3 -6
- package/dist/react-tooltip.esm.min.js +1 -1
- package/dist/react-tooltip.umd.js +3 -6
- package/dist/react-tooltip.umd.min.js +1 -1
- package/jest.config.ts +214 -0
- package/package.json +12 -4
- package/tsconfig.json +2 -2
- package/.github/FUNDING.yml +0 -13
- package/.github/workflows/lint.yaml +0 -35
- package/.github/workflows/pull-request.yaml +0 -11
- package/.github/workflows/release.yaml +0 -30
- package/.husky/pre-commit +0 -6
- package/.vscode/settings.json +0 -27
- package/build/dist/react-tooltip.cjs.js +0 -2909
- package/build/dist/react-tooltip.cjs.min.js +0 -6
- package/build/dist/react-tooltip.css +0 -73
- package/build/dist/react-tooltip.esm.js +0 -2901
- package/build/dist/react-tooltip.esm.min.js +0 -6
- package/build/dist/react-tooltip.min.css +0 -1
- package/build/dist/react-tooltip.umd.js +0 -2913
- package/build/dist/react-tooltip.umd.min.js +0 -6
- package/build/index.css +0 -79
- package/build/index.html +0 -19
- package/build/index.js +0 -36190
- package/docs/README.md +0 -50
- package/docs/babel.config.js +0 -3
- package/docs/docs/examples/_category_.json +0 -7
- package/docs/docs/examples/basic-examples.mdx +0 -68
- package/docs/docs/examples/children.mdx +0 -67
- package/docs/docs/examples/content.mdx +0 -80
- package/docs/docs/examples/delay.mdx +0 -84
- package/docs/docs/examples/events.mdx +0 -85
- package/docs/docs/examples/get-content.mdx +0 -58
- package/docs/docs/examples/html.mdx +0 -75
- package/docs/docs/examples/multiline.mdx +0 -91
- package/docs/docs/examples/offset.mdx +0 -69
- package/docs/docs/examples/place.mdx +0 -55
- package/docs/docs/examples/state.mdx +0 -331
- package/docs/docs/examples/styling.mdx +0 -388
- package/docs/docs/examples/variant.mdx +0 -100
- package/docs/docs/getting-started.mdx +0 -100
- package/docs/docs/options.mdx +0 -105
- package/docs/docs/upgrade-guide/_category_.json +0 -7
- package/docs/docs/upgrade-guide/basic-examples-v4-v5.mdx +0 -119
- package/docs/docs/upgrade-guide/changelog-v4-v5.md +0 -86
- package/docs/docusaurus.config.js +0 -135
- package/docs/package.json +0 -47
- package/docs/sidebars.js +0 -33
- package/docs/src/components/HomepageFeatures/index.tsx +0 -71
- package/docs/src/components/HomepageFeatures/styles.module.css +0 -11
- package/docs/src/css/custom.css +0 -74
- package/docs/src/pages/index.module.css +0 -35
- package/docs/src/pages/index.tsx +0 -45
- package/docs/src/pages/markdown-page.md +0 -7
- package/docs/static/.nojekyll +0 -0
- package/docs/static/img/Octocat.jpg +0 -0
- package/docs/static/img/Octocat.png +0 -0
- package/docs/static/img/Octocat.svg +0 -9
- package/docs/static/img/android-chrome-192x192.png +0 -0
- package/docs/static/img/android-chrome-512x512.png +0 -0
- package/docs/static/img/apple-touch-icon.png +0 -0
- package/docs/static/img/docusaurus.png +0 -0
- package/docs/static/img/favicon-16x16.png +0 -0
- package/docs/static/img/favicon-32x32.png +0 -0
- package/docs/static/img/favicon-old.ico +0 -0
- package/docs/static/img/favicon.ico +0 -0
- package/docs/static/img/github.svg +0 -1
- package/docs/static/img/happy-face-tooltip.png +0 -0
- package/docs/static/img/happy-face-tooltip.svg +0 -21
- package/docs/static/img/logo-dinossaur.svg +0 -1
- package/docs/static/img/logo.png +0 -0
- package/docs/static/img/logo.svg +0 -21
- package/docs/static/img/only-tooltip-top.png +0 -0
- package/docs/static/img/only-tooltip-top.svg +0 -4
- package/docs/static/img/only-tooltip.png +0 -0
- package/docs/static/img/only-tooltip.svg +0 -4
- package/docs/static/img/site.webmanifest +0 -1
- package/docs/static/img/undraw_docusaurus_mountain.svg +0 -171
- package/docs/static/img/undraw_docusaurus_react.svg +0 -170
- package/docs/static/img/undraw_docusaurus_tree.svg +0 -40
- package/docs/tsconfig.json +0 -7
- package/docs/yarn.lock +0 -7599
- package/example-v5/package.json +0 -21
- package/example-v5/public/index.html +0 -20
- package/example-v5/public/manifest.json +0 -8
- package/example-v5/src/App.jsx +0 -908
- package/example-v5/src/index.css +0 -238
- package/example-v5/src/index.js +0 -15
- package/example-v5/src/index.scss +0 -251
- package/public/index.html +0 -19
package/.eslintrc.json
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
## Code of Conduct
|
|
2
|
+
|
|
3
|
+
### Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
### Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
- Demonstrating empathy and kindness toward other people
|
|
14
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
- Giving and gracefully accepting constructive feedback
|
|
16
|
+
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
- Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
- The use of sexualized language or imagery, and sexual attention or advances of any kind
|
|
22
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
23
|
+
- Public or private harassment
|
|
24
|
+
- Publishing others’ private information, such as a physical or email address, without their explicit permission
|
|
25
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
26
|
+
|
|
27
|
+
### Enforcement Responsibilities
|
|
28
|
+
|
|
29
|
+
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
+
|
|
31
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
32
|
+
|
|
33
|
+
### Scope
|
|
34
|
+
|
|
35
|
+
This Code of Conduct applies within all community spaces and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
36
|
+
|
|
37
|
+
### Enforcement
|
|
38
|
+
|
|
39
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project team responsible for enforcement. All complaints will be reviewed and investigated promptly and fairly.
|
|
40
|
+
|
|
41
|
+
All project maintainers are obligated to respect the privacy and security of the reporter of any incident.
|
|
42
|
+
|
|
43
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
44
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
45
|
+
members of the project's leadership.
|
|
46
|
+
|
|
47
|
+
### Attribution
|
|
48
|
+
|
|
49
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1,
|
|
50
|
+
available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct/][version]
|
|
51
|
+
|
|
52
|
+
[homepage]: http://contributor-covenant.org
|
|
53
|
+
[version]: https://www.contributor-covenant.org/version/2/1
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2022 ReactTooltip Team Github
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
-
|
package/README.md
CHANGED
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
## Demo
|
|
13
13
|
|
|
14
|
-
[](https://codesandbox.io/s/
|
|
14
|
+
[](https://codesandbox.io/s/still-monad-yfi4fn?fontsize=14&hidenavigation=1&theme=dark)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Documentation for V4 - [Github Page](https://reacttooltip.github.io/react-tooltip/).
|
|
17
|
+
|
|
18
|
+
Documentation for V5 - [ReactTooltip](https://react-tooltip.com/docs/getting-started).
|
|
17
19
|
|
|
18
20
|
## Installation
|
|
19
21
|
|
|
@@ -34,67 +36,44 @@ yarn add react-tooltip
|
|
|
34
36
|
1 . Require react-tooltip after installation
|
|
35
37
|
|
|
36
38
|
```js
|
|
37
|
-
import
|
|
39
|
+
import { Tooltip } from 'react-tooltip'
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
or if you want to still use the name ReactTooltip as V4:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import { Tooltip as ReactTooltip } from 'react-tooltip'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2 . Add data-tooltip-content = "your placeholder" to your element
|
|
41
49
|
|
|
42
50
|
```jsx
|
|
43
|
-
<p data-
|
|
51
|
+
<p id="my-element" data-tooltip-content="hello world">
|
|
52
|
+
Tooltip
|
|
53
|
+
</p>
|
|
44
54
|
```
|
|
45
55
|
|
|
46
56
|
3 . Include react-tooltip component
|
|
47
57
|
|
|
48
58
|
```jsx
|
|
49
|
-
<ReactTooltip />
|
|
59
|
+
<ReactTooltip anchorId="my-element" />
|
|
50
60
|
```
|
|
51
61
|
|
|
52
62
|
### Standalone
|
|
53
63
|
|
|
54
|
-
You can import `node_modules/react-tooltip/dist/
|
|
64
|
+
You can import `node_modules/react-tooltip/dist/react-tooltip.[mode].js` into your page. Please make sure that you have already imported `react` and `react-dom` into your page.
|
|
65
|
+
|
|
66
|
+
mode: `esm` `cjs` `umd`
|
|
67
|
+
|
|
68
|
+
If you want to use default ReactTooltip styles, don't forget to import the styles: `node_modules/react-tooltip/dist/react-tooltip.css`
|
|
69
|
+
|
|
70
|
+
PS: all the files has a minified version and a not minified version.
|
|
71
|
+
|
|
72
|
+

|
|
55
73
|
|
|
56
74
|
## Options
|
|
57
75
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- The tooltip sets `type: dark` `place: top` `effect: float` as **default** attributes. You don't have to add these options if you don't want to change the defaults
|
|
61
|
-
- The option you set on `<ReactTooltip />` component will be implemented on every tooltip in a same page: `<ReactTooltip effect="solid" />`
|
|
62
|
-
- The option you set on a specific element, for example: `<a data-type="warning"></a>` will only affect this specific tooltip
|
|
63
|
-
|
|
64
|
-
| Global | Specific | Type | Values | Description |
|
|
65
|
-
| :------------------- | :-------------------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
66
|
-
| place | data-place | String | "top", "right", "bottom", "left", or comma-separated e.g. "left,right" | placement - can specify a comma-separated list of preferences that will be attempted in order |
|
|
67
|
-
| type | data-type | String | dark, success, warning, error, info, light | theme |
|
|
68
|
-
| effect | data-effect | String | float, solid | behaviour of tooltip |
|
|
69
|
-
| event | data-event | String | e.g. click | custom event to trigger tooltip |
|
|
70
|
-
| eventOff | data-event-off | String | e.g. click | custom event to hide tooltip (only makes effect after setting event attribute) |
|
|
71
|
-
| globalEventOff | | String | e.g. click | global event to hide tooltip (global only) |
|
|
72
|
-
| isCapture | data-iscapture | Bool | true, false | when set to true, custom event's propagation mode will be capture |
|
|
73
|
-
| offset | data-offset | Object | { top?: number, right?: number, bottom?: number, left?: number } | `data-offset="{'top': 10, 'left': 10}"` for specific and `offset={{top: 10, left: 10}}` for global |
|
|
74
|
-
| padding | data-padding | String | e.g. `8px 21px` | Popup padding style |
|
|
75
|
-
| multiline | data-multiline | Bool | true, false | support `<br>`, `<br />` to make multiline |
|
|
76
|
-
| className | data-class | String | | extra custom class, can use !important to overwrite react-tooltip's default class |
|
|
77
|
-
| html | data-html | Bool | true, false | `<p data-tip="<p>HTML tooltip</p>" data-html={true}></p>` or `<ReactTooltip html={true} />`, but see [Security Note](#security-note) below.<br/>When using JSX, see [this note](#jsx-note) below. |
|
|
78
|
-
| delayHide | data-delay-hide | Number | | `<p data-tip="tooltip" data-delay-hide='1000'></p>` or `<ReactTooltip delayHide={1000} />` |
|
|
79
|
-
| delayShow | data-delay-show | Number | | `<p data-tip="tooltip" data-delay-show='1000'></p>` or `<ReactTooltip delayShow={1000} />` |
|
|
80
|
-
| delayUpdate | data-delay-update | Number | | `<p data-tip="tooltip" data-delay-update='1000'></p>` or `<ReactTooltip delayUpdate={1000} />` Sets a delay in calling getContent if the tooltip is already shown and you mouse over another target |
|
|
81
|
-
| insecure | null | Bool | true, false | Whether to inject the style header into the page dynamically (violates CSP style-src but is a convenient default) |
|
|
82
|
-
| border | data-border | Bool | true, false | Add one pixel white border |
|
|
83
|
-
| borderClass | data-border-class | String | e.g. custom-border-class | A custom class name to use for the border - enabled by the `border` prop |
|
|
84
|
-
| textColor | data-text-color | String | e.g. red | Popup text color |
|
|
85
|
-
| backgroundColor | data-background-color | String | e.g. yellow | Popup background color |
|
|
86
|
-
| borderColor | data-border-color | String | e.g. green | Popup border color - enabled by the `border` value |
|
|
87
|
-
| arrowColor | data-arrow-color | String | e.g. #fff | Popup arrow color - if not specified, will use the `backgroundColor` value |
|
|
88
|
-
| getContent | null | Func or Array | (dataTip) => {}, [(dataTip) => {}, Interval] | Generate the tip content dynamically |
|
|
89
|
-
| afterShow | null | Func | (evt) => {} | Function that will be called after tooltip show, with event that triggered show |
|
|
90
|
-
| afterHide | null | Func | (evt) => {} | Function that will be called after tooltip hide, with event that triggered hide |
|
|
91
|
-
| overridePosition | null | Func | ({left:number, top: number}, currentEvent, currentTarget, node, place, desiredPlace, effect, offset) => ({left: number, top: number}) | Function that will replace tooltip position with custom one |
|
|
92
|
-
| disable | data-tip-disable | Bool | true, false | Disable the tooltip behaviour, default is false |
|
|
93
|
-
| scrollHide | data-scroll-hide | Bool | true, false | Hide the tooltip when scrolling, default is true |
|
|
94
|
-
| resizeHide | null | Bool | true, false | Hide the tooltip when resizing the window, default is true |
|
|
95
|
-
| wrapper | null | String | div, span | Selecting the wrapper element of the react tooltip, default is div |
|
|
96
|
-
| clickable | null | Bool | true, false | Enables tooltip to respond to mouse (or touch) events, default is false |
|
|
97
|
-
| disableInternalStyle | null | Bool | true, false | Disable internal styles to let custom styling of the tooltip being added |
|
|
76
|
+
For all available options, please check [React Tooltip Options](https://react-tooltip.com/docs/options)
|
|
98
77
|
|
|
99
78
|
### Security Note
|
|
100
79
|
|
|
@@ -102,121 +81,20 @@ The `html` option allows a tooltip to directly display raw HTML. This is a secur
|
|
|
102
81
|
|
|
103
82
|
#### JSX Note
|
|
104
83
|
|
|
105
|
-
You can use React's [`renderToStaticMarkup`-function](https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup) to use JSX instead of HTML.
|
|
84
|
+
You can use React's [`renderToStaticMarkup`-function](https://reactjs.org/docs/react-dom-server.html#rendertostaticmarkup) to use JSX instead of HTML.
|
|
106
85
|
**Example:**
|
|
107
86
|
|
|
108
87
|
```jsx
|
|
109
88
|
import ReactDOMServer from 'react-dom/server';
|
|
110
89
|
[...]
|
|
111
|
-
<p
|
|
90
|
+
<p id="my-element" data-tooltip-html={ReactDOMServer.renderToString(<div>I am <b>JSX</b> content</div>)}>
|
|
112
91
|
Hover me
|
|
113
92
|
</p>
|
|
114
93
|
```
|
|
115
94
|
|
|
116
95
|
#### Note
|
|
117
96
|
|
|
118
|
-
|
|
119
|
-
2. **data-for** corresponds to the **id** of `<ReactTooltip />`
|
|
120
|
-
3. When using react component as tooltip, you can have many `<ReactTooltip />` in a page but they should have different **id**s
|
|
121
|
-
|
|
122
|
-
## Static Methods
|
|
123
|
-
|
|
124
|
-
### ReactTooltip.hide(target)
|
|
125
|
-
|
|
126
|
-
> Hide the tooltip manually, the target is optional, if no target passed in, all existing tooltips will be hidden
|
|
127
|
-
|
|
128
|
-
```jsx
|
|
129
|
-
import ReactTooltip from 'react-tooltip'
|
|
130
|
-
|
|
131
|
-
<p ref={ref => this.fooRef = ref} data-tip='tooltip'></p>
|
|
132
|
-
<button onClick={() => { ReactTooltip.hide(this.fooRef) }}></button>
|
|
133
|
-
<ReactTooltip />
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### ReactTooltip.rebuild()
|
|
137
|
-
|
|
138
|
-
> Rebinding all tooltips
|
|
139
|
-
|
|
140
|
-
### ReactTooltip.show(target)
|
|
141
|
-
|
|
142
|
-
> Show specific tooltip manually, for example:
|
|
143
|
-
|
|
144
|
-
```jsx
|
|
145
|
-
import ReactTooltip from 'react-tooltip'
|
|
146
|
-
|
|
147
|
-
<p ref={ref => this.fooRef = ref} data-tip='tooltip'></p>
|
|
148
|
-
<button onClick={() => { ReactTooltip.show(this.fooRef) }}></button>
|
|
149
|
-
<ReactTooltip />
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Troubleshooting
|
|
153
|
-
|
|
154
|
-
### 1. Using tooltip within the modal (e.g. [react-modal](https://github.com/reactjs/react-modal))
|
|
155
|
-
|
|
156
|
-
The component was designed to set `<ReactTooltip />` once and then use tooltip everywhere, but a lot of people get stuck when using this component in a modal. You can read the discussion [here](https://github.com/wwayne/react-tooltip/issues/130). To solve this problem:
|
|
157
|
-
|
|
158
|
-
1. Place `<ReactTooltip />` outside of the `<Modal>`
|
|
159
|
-
2. Use `ReactTooltip.rebuild()` when opening the modal
|
|
160
|
-
3. If your modal's z-index happens to be higher than the tooltip's, use the attribute `className` to custom your tooltip's z-index
|
|
161
|
-
|
|
162
|
-
> I suggest always putting `<ReactTooltip />` in the Highest level or smart component of Redux, so you might need these static
|
|
163
|
-
> method to control tooltip's behaviour in some situations
|
|
164
|
-
|
|
165
|
-
### 2. Hide tooltip when getContent returns undefined
|
|
166
|
-
|
|
167
|
-
When you set `getContent={() => { return }}` you will find the tooltip will display `true`. That's because React will set the value of data-\* to be 'true' automatically if there is no value to be set. So you have to set `data-tip=''` in this situation.
|
|
168
|
-
|
|
169
|
-
```jsx
|
|
170
|
-
<p data-tip='' data-for='test'></p>
|
|
171
|
-
<ReactTooltip id='test' getContent={() => { return null }}/>
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Same for empty children, if you don't want show the tooltip when the children is empty
|
|
175
|
-
|
|
176
|
-
```jsx
|
|
177
|
-
<p data-tip='' data-for='test'></p>
|
|
178
|
-
<ReactTooltip id='test'>{}</ReactTooltip>
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### 3. Tooltip not binding to dynamic content
|
|
182
|
-
|
|
183
|
-
When you render `<ReactTooltip>` ahead of dynamic content, and are using `data-for={id}` attributes
|
|
184
|
-
on new dynamic content, the tooltip will not register its event listener.
|
|
185
|
-
|
|
186
|
-
For example, you render a generic tooltip in the root of your app, then load a list of content async.
|
|
187
|
-
Elements in the list use the `data-for={id}` attribute to bind the tooltip on hover.
|
|
188
|
-
Since the tooltip has already scanned for data-tip these new elements will not trigger.
|
|
189
|
-
|
|
190
|
-
One workaround for this is to trigger `ReactTooltip.rebuild()` after the data load to scan for the attribute again,
|
|
191
|
-
to allow event wireup.
|
|
192
|
-
|
|
193
|
-
#### Example
|
|
194
|
-
|
|
195
|
-
```jsx
|
|
196
|
-
<app>
|
|
197
|
-
<ReactTooltip id="foo" />
|
|
198
|
-
<list />
|
|
199
|
-
</app>
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
```jsx
|
|
203
|
-
|
|
204
|
-
const dynamicList = (props) => {
|
|
205
|
-
|
|
206
|
-
useEffect(() => {
|
|
207
|
-
ReactTooltip.rebuild();
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
return(
|
|
211
|
-
<list>
|
|
212
|
-
{data.map((item)=> {
|
|
213
|
-
<span data-for="foo">My late bound tooltip triggered data</span>
|
|
214
|
-
});}
|
|
215
|
-
</list>
|
|
216
|
-
);
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
```
|
|
97
|
+
- **id** is necessary, because `<ReactTooltip anchorId="my-element" />` finds the tooltip via this attribute
|
|
220
98
|
|
|
221
99
|
## Article
|
|
222
100
|
|
|
@@ -224,7 +102,7 @@ return(
|
|
|
224
102
|
|
|
225
103
|
## Maintainers
|
|
226
104
|
|
|
227
|
-
[danielbarion](https://github.com/danielbarion)
|
|
105
|
+
[danielbarion](https://github.com/danielbarion) maintainer - accepting PRs and doing minor testing/development.
|
|
228
106
|
|
|
229
107
|
[alexgurr](https://github.com/alexgurr) Casual maintainer - accepting PRs and doing minor testing/development.
|
|
230
108
|
|