question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

behavior I don't understand, is this a quirk of react or react-tooltip?

See original GitHub issue

If I put

<ReactTooltip />

in a ‘high level’ component and put

<p data-tip="hello world">Tooltip</p>

nested about 3 components down then tooltips don’t show. However, if I put a

<p data-tip="hello world">Tooltip</p>

half way between them the lower level tooltips work, but only if I mouse over the mid level tooltip first.

If I put

<ReactTooltip />

in the ‘middle’ then tooltips from all nested levels work.

If I browse through the DOM I can see all the nodes in the right places, it just seems like the ReactTooltip javascript event isn’t setting up or it can’t see the tooltip node at a distance.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:22 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
kswopecommented, Oct 12, 2015

I only ever put <ReactTooltip /> in one place, which makes sense to me. I only import it in that same file. But in order for the tooltips to work, I have to <p data-tip="hello world">Tooltip</p> either in the same component or a component close to it (maybe it has to be on the same ‘side’ of the smart component, I’m not sure). Once I put <p data-tip="hello world">Tooltip</p> In a component ‘close’ to where its required, the tooltips everywhere start working.

I can confirm that putting ReactTooltip.rebuild() in componentDidMount (and reloading page) does NOT work, but in componentDidUpdate DOES work.

This is not such a problem for me, I thought I’d just point out this strange behavior. I’m not sure how smart components in redux work but it looks like some voodoo is going on there and it might be interfering with react-tooltips, or it might have nothing to do with it, but thats all I can think of.

Good looking tooltips btw 👍

2reactions
wwaynecommented, Oct 12, 2015

If I’m not misunderstand, the code structure you said is as follows:

<div>
<HighLevel>
   <MiddleLevel>
       <LowLevel />
   </MiddleLevel>
</HighLevel>
<ReactTooltip />
</div>

LowLevel: 
render () {
 return (
   <p data-tip='xxx'></p>
 )
}

If so, on my test, this works good. So I suppose you mount the lower level component after triggering some actions?

There is a ReactTooltip.rebuild() function to ‘re-bind’ tooltip, so I think you can take a try by

import ReactTooltip from 'react-tooltip'
export default class MiddleLevel extends React.Component {
  componentDidMount () {
     React.rebuild()
  }
}

Let me know if I misunderstand your problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

behavior I don't understand, is this a quirk of react or ... - GitHub
I happened to use Redux and react-tooltip in my recent project, I put <ReactTooltip /> in the smart component and use it in...
Read more >
react-tooltip - npm
The component was designed to set <ReactTooltip /> once and then use tooltip everywhere, but a lot of people get stuck when using...
Read more >
The Little React Quirk I Wish I'd Known Sooner
Knowing the internals is probably not necessary to build React apps but by understanding the underlying concepts, you should be able to write...
Read more >
React tooltip, dont show beside the element - Stack Overflow
The tooltip is supposed to know where to appear based on the element it is for (the <a> in the <li> element in...
Read more >
React Tooltip component - Material UI - MUI
They don't have directional arrows; instead, they rely on motion ... You can use the open , onOpen and onClose props to control...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found