When there is a element that using a variable for content of tooltip and the variable is null first, then the tooltip will not shown, for example below.
render() {
let disabled = this.whatEveryFunction();
let tip = disabled ? 'Show something' : null;
return (
<div>
<p data-tip="always show something"></p>
<button data-tip={tip}>Save</button>
<ReactTooltip />
</div>
)
}
It will works if I change null to empty string, is it a bug or something?
@donilan that's because the tooltip only accept String
@donilan you can also call ReactTooltip.rebuild() to re-bind tooltips. I'm using this in a componentDidUpdate hook to re-bind tooltips as data changes.
@asidiali is Correct Snippet
useEffect(() => {
ReactTooltip.rebuild()
});
Most helpful comment
@donilan you can also call
ReactTooltip.rebuild()to re-bind tooltips. I'm using this in acomponentDidUpdatehook to re-bind tooltips as data changes.