This website collects cookies to deliver better user experience
☢️ HTML Comment in React
☢️ HTML Comment in React
If you ever started learning React and saw it's syntax JSX, you maybe thought. "This looks like HTML"
And one day you want to comment something in JSX, and your first try would be to do:
functionComponent(){return(<div> <!-- This is my comment -->
The quick brown fox ...
</div>)}
And for sure your bundler started complaining, that your syntax is invalid, and then you search the internet, and realise that a HTML Comment is not valid in JSX, and you learn that you have to use a JavaScript comment.
Well in this blog post I will show you for learning purposes how to trick React to render a real HTML Comment in your browser in a few steps.