There is React code as below:
export default function App() { return ( <div> <span dangerouslySetInnerHTML={{ __html: `<!-- comment -->` }}></span> <h2>i want comment rendering!!!</h2> </div> ); } The above code is rendered as follows:
But I'd like it to render like this:
So, I would like to ask if there is a way to render HTML Comments in React without a Wrapper Element.
https://www.reddit.com/r/reactjs/comments/11kiy7k/alternatives_to_dangerouslysetinnerhtml/?rdt=36706
https://www.npmjs.com/package/isomorphic-dompurify
How to render a HTML comment in React?
I searched hard, including the links above, but couldn't find a solution.


<span>tag that contains a comment. Why would you expect the span to be suppressed?