It is not recommended to use this approach in JSX, as it goes against the concept of virtual DOM and does not create virtual nodes.
Instead, consider trying something like this:
this.greeting = 'Hello';
this.person='world';
When binding data:
<h1>{this.greeting} <b>{this.person}</b></h1>
If the situation is more complex, consider creating a smaller component instead.
While using innerHTML
can work, it is advisable to only do so in specific situations. For more information, refer to the details here(at the bottom of the page).