react-tooltip 5.10.6-beta.1009.1 → 5.11.0
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/README.md +93 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -153,6 +153,99 @@ import ReactDOMServer from 'react-dom/server';
|
|
|
153
153
|
</a>
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
+
## Troubleshooting
|
|
157
|
+
|
|
158
|
+
Before trying these, make sure you're running the latest ReactTooltip version with
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
npm install react-tooltip@latest
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
or
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
yarn add react-tooltip@latest
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
If you can't find your problem here, make sure there isn't [an open issue](https://github.com/ReactTooltip/react-tooltip/issues) already covering it.
|
|
171
|
+
If there isn't, feel free to [submit a new issue](https://github.com/ReactTooltip/react-tooltip/issues/new/choose).
|
|
172
|
+
|
|
173
|
+
### The tooltip is broken/not showing up
|
|
174
|
+
|
|
175
|
+
Make sure you've imported the default styling. You only need to do this once on your application, `App.jsx`/`App.tsx` is usually a good place to do it.
|
|
176
|
+
|
|
177
|
+
```jsx
|
|
178
|
+
import 'react-tooltip/dist/react-tooltip.css'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
If you've imported the default styling and the tooltip is still not showing up when you hover on your anchor element, make sure you have content to be displayed by the tooltip.
|
|
182
|
+
|
|
183
|
+
If `data-tooltip-content` and `data-tooltip-html` are both unset (or they have empty values) on the anchor element, and also the `content`, `render`, and `children` props on the tooltip are unset (or have empty values), the tooltip is not shown by default.
|
|
184
|
+
|
|
185
|
+
### Next.js `TypeError: f is not a function`
|
|
186
|
+
|
|
187
|
+
This problem seems to be caused by a bug related to the SWC bundler used by Next.js.
|
|
188
|
+
The best way to solve this is to upgrade to `next@13.3.0` or later versions.
|
|
189
|
+
|
|
190
|
+
Less ideally, if you're unable to upgrade, you can set `swcMinify: false` on your `next.config.js` file.
|
|
191
|
+
|
|
192
|
+
### Bad performance
|
|
193
|
+
|
|
194
|
+
If you're experiencing any kind of unexpected behavior or bad performance on your application when using ReactTooltip, here are a few things you can try.
|
|
195
|
+
|
|
196
|
+
#### Move `<Tooltip />` on the DOM
|
|
197
|
+
|
|
198
|
+
This is specially relevant when using components that are conditionally rendered.
|
|
199
|
+
|
|
200
|
+
Always try to keep the `<Tooltip />` component rendered, so if you're having issues with a tooltip you've placed inside a component which is placed/removed from the DOM dynamically, try to move the tooltip outside of it.
|
|
201
|
+
|
|
202
|
+
We usually recommend placing the tooltip component directly inside the root component of your application (usually on `App.jsx`/`App.tsx`). You can also move the `import 'react-tooltip/dist/react-tooltip.css'` there.
|
|
203
|
+
|
|
204
|
+
#### Dynamically generated anchor elements
|
|
205
|
+
|
|
206
|
+
You should avoid needlessly using a large amount of `<Tooltip />` components. One tooltip component that you use across your whole application should be good enough in most cases, but you should be fine to add a few more if you need to use different styled tooltips.
|
|
207
|
+
|
|
208
|
+
Here's a simple example on how to improve performance when using dynamically generated items.
|
|
209
|
+
|
|
210
|
+
> Check the docs for examples for the [`anchorSelect`](https://react-tooltip.com/docs/examples/anchor-select) and [`render`](https://react-tooltip.com/docs/examples/render) props for more complex use cases.
|
|
211
|
+
|
|
212
|
+
```jsx
|
|
213
|
+
// ❌ BAD
|
|
214
|
+
<div className="items-container">
|
|
215
|
+
{
|
|
216
|
+
myItems.map(({ id, content, tooltip }) => (
|
|
217
|
+
<div
|
|
218
|
+
key={id}
|
|
219
|
+
className="item"
|
|
220
|
+
data-tooltip-id={`tooltip-${id}`}
|
|
221
|
+
>
|
|
222
|
+
{content}
|
|
223
|
+
<Tooltip id={`tooltip-${id}`} content={tooltip} />
|
|
224
|
+
</div>
|
|
225
|
+
))
|
|
226
|
+
}
|
|
227
|
+
</div>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
```jsx
|
|
231
|
+
// ✅ GOOD
|
|
232
|
+
<div className="items-container">
|
|
233
|
+
{
|
|
234
|
+
myItems.map(({ id, content, tooltip }) => (
|
|
235
|
+
<div
|
|
236
|
+
key={id}
|
|
237
|
+
className="item"
|
|
238
|
+
data-tooltip-id="my-tooltip"
|
|
239
|
+
data-tooltip-content={tooltip}
|
|
240
|
+
>
|
|
241
|
+
{content}
|
|
242
|
+
</div>
|
|
243
|
+
))
|
|
244
|
+
}
|
|
245
|
+
</div>
|
|
246
|
+
<Tooltip id="my-tooltip" />
|
|
247
|
+
```
|
|
248
|
+
|
|
156
249
|
## Article
|
|
157
250
|
|
|
158
251
|
[How I insert sass into react component](https://medium.com/@wwayne_me/how-i-insert-sass-into-my-npm-react-component-b46b9811c226#.gi4hxu44a)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-tooltip",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "react tooltip component",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev-rollup": "node ./prebuild.js --env=development && node --max_old_space_size=2048 ./node_modules/rollup/dist/bin/rollup -c rollup.config.dev.js --watch",
|