I can not figure it out that how is it possible to use HTML in a data attribute inside React's jsx.
Like
data-bs-template='<div class="tooltip d-none d-md-block" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
Is this approach right or wrong?
In order set HTML in a React component, you need to create an object that has the
__html
property and the a string that contains the relevant HTML markup. Like this:And finally render it using
dangerouslySetInnerHTML
which is React's replacement for the nativeinnerHTML
: