Without using refs / React DOM, you can select tooltips by data-toggle attribute:
componentDidMount() {
$('[data-toggle="tooltip"]').tooltip();
}
componentDidUpdate() {
$('[data-toggle="tooltip"]').tooltip();
}
Source: Bootstrap documentation
Note, if you're loading jQuery by CDN, you can refer to it by window.$ as well.
Answer from devonj on Stack OverflowHow do use bootstrap tooltips with React?
react-bootstrap: how to implement tooltip with checkbox?
Popper 2 released! The popular positioning engine for tooltips and popovers, used by Material UI, Bootstrap, and more
[tutorial] Build tooltips with React Hooks. It's harder than I thought it'd be heh
Why are you using global state (contexts) for this?
You could create multiple tooltip components that each just receive props and calculate position based on either their place in the render tree or the trigger element (a ref of the element you hover over)
Or if you wanted to stick to one component and reuse it with new position you could use a portal and absolutely position it
More on reddit.comWithout using refs / React DOM, you can select tooltips by data-toggle attribute:
componentDidMount() {
$('[data-toggle="tooltip"]').tooltip();
}
componentDidUpdate() {
$('[data-toggle="tooltip"]').tooltip();
}
Source: Bootstrap documentation
Note, if you're loading jQuery by CDN, you can refer to it by window.$ as well.
I know it s an old question, but to avoid side effects with bootstrap/jquery/react, if you want tooltips, use this :
https://www.npmjs.com/package/react-tooltip
It's very easy to use and works better than bootstrap tooltip in a react project
» npm install react-bootstrap-tooltip-button