Replies: 2 comments 3 replies
-
Interesting idea to use a |
Beta Was this translation helpful? Give feedback.
-
Looking at how we would use the component you proposed, and it would work in the case you mentioned but not with comments that include React inside, such as: <!--[if mso]>
<p>This is meant for Outlook only</p>
<![endif]--> Another, more general idea would be to have a sort of |
Beta Was this translation helpful? Give feedback.
-
Goals
Background
React does not natively support adding HTML comments in JSX. The common workaround, using the
dangerouslySetInnerHTML
prop, is limited as it only works inside of HTML element. This limitation becomes apparent when HTML comments need to act as wrappers around other Components, such as:Proposal
Introduce a Comment component and a replaceCommentPlaceholder method to manage HTML comments effectively:
Comment
Component: This component acts as a custom HTML tag, which will be ignored by the browser due to thehidden
attribute during development.replaceCommentPlaceholder
Method: This method replaces all comment placeholders with actual HTML comments. It should be used for all render methods to ensure that the comments are correctly inserted into the final HTML output.Beta Was this translation helpful? Give feedback.
All reactions