ReactTooltip getContent callback is called more than once for a ReactTooltip component with effect="solid"
See original GitHub issueAfter rendering the following component:
export default class TestComponent extends React.PureComponent {
constructor(props) {
super(props)
this.tooltipId = elementUniqueId() // Creates a unique ID. I checked the DOM and this ID is always unique.
}
render() {
const tooltip = 'TEST!!!'
console.warn('render()')
return (
<div>
<span data-tip={tooltip}
data-for={this.tooltipId}>
HOVER ME!
</span>
<ReactTooltip id={this.tooltipId}
effect="solid"
place="right"
getContent={function() {
console.warn('getContent()')
return (
<div>{tooltip}</div>
)
}} />
</div>
)
}
}
I see the following in the console:
> console.warn('render()') // OK
> console.warn('getContent()') // OK
At this point, the tooltip hasn’t been shown yet.
From this point on, each time I hover the span
element to trigger the tooltip, I can see in the console that getContent()
is always called 3 times when the mouse hovers the element showing the tooltip and 2 times when the mouse leaves the element:
// I hover the span element (the tooltip shows):
> console.warn('getContent()') // OK
> console.warn('getContent()') // NOT OK. Why is the callback called again?
> console.warn('getContent()') // NOT OK. And again?
// I move the mouse out of the span element (the tooltip hides):
> console.warn('getContent()') // NOT OK. Why does it call getContent in the first place if the tooltip is hiding?
> console.warn('getContent()') // NOT OK. Why does it call getContent in the first place if the tooltip is hiding?
Also, I noticed that getContent
is called several times if I resize the browser’s page even if the tooltip is not showing.
Am I missing something or this is the actual behaviour and if so why does it work like this?
Anyway, I would like to that you for this component and for your attention.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7
Top Results From Across the Web
ReactTooltip getContent callback is called more than once for ...
After rendering the following component: export default class TestComponent extends React.PureComponent { constructor(props) { super(props) ...
Read more >react-tooltip - Bountysource
ReactTooltip getContent callback is called more than once for a ReactTooltip component with effect="solid" $ 0 ... Created 3 years ago in wwayne/react-tooltip ......
Read more >React-tooltip rendering two times - Stack Overflow
Then I have this other component where I pass some props to the Tooltip component and I just want this only component to...
Read more >React-tooltip vs Material UI Tooltip Comparison and Examples
Then we dive into how Material UI uses Popper.js, and how we can build an interactive Tooltip that stays open while interacting with...
Read more >React tooltip Component - Morioh
The component was designed to set <ReactTooltip /> once and then use tooltip everywhere ... If your modal's z-index happens to be higher...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a grid of elements with tooltips on each item debouncing
getContent
and keeping only trailing one did the job:I was calling the memoize function 200 times _M_renderCrewLocation = memoize(this.renderCrewLocation)
I moved the memoize into the constructor