-
Notifications
You must be signed in to change notification settings - Fork 45.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSX parser should support XML-style comments #21601
Comments
Fun fact: HTML-style comments are valid ECMAScript comments when the host is a web browser (excluding modules) From the spec: https://tc39.es/ecma262/#sec-html-like-comments (you might have to search "HTML" for the section to appear) |
I'm currently looking for a way to add HTML comments to my page (for attributions and other comments potentially useful for whoever reads the HTML source) but as @crizzis said, it's not supported by the JSX parser. I've found some workarounds here and there, like Stack Overflow: How to render a HTML comment in React?, but these solutions have a lot of boilerplate just for an HTML comment, and I don't think they are easily readable/understandable by someone looking at the code. TLDR: I think it would be useful to have HTML comments supported in JSX out of the box to avoid the hassle of finding a workaround/package just to write a comment. |
I need this feature too. Current workaround from stackoverflow has many disadvantages. We have to:
|
The thing is, that things like Internet Explorer Comment conditionals can't end within a tag like this |
We're not actively changing JSX at the moment. But if you'd like to propose a change, https://github.com/facebook/jsx would be the right place. |
It would be a nice feature if the JSX parser could recognize XML-style comments (
<!-- -->
), either by ignoring them completely or by passing the comments through to the output HTML.Right now, using XML-style comments results in compilation errors.
The text was updated successfully, but these errors were encountered: