Skip to content

Files

Latest commit

 

History

History
27 lines (20 loc) · 595 Bytes

jsx-no-comment-textnodes.md

File metadata and controls

27 lines (20 loc) · 595 Bytes

Pattern: Comment string in JSX text node

Issue: -

Description

JSX treats any text within elements as literal content to be rendered. This can cause comments (starting with // or /*) to appear as unwanted text in the output instead of being treated as comments when not properly wrapped in curly braces.

Examples

Example of incorrect code:

const Hello = () => {
  return <div>// empty div</div>;
};

const Hello = () => {
  return <div>/* empty div */</div>;
};

Example of correct code:

const Hello = () => {
  return <div>{/* empty div */}</div>;
};