JSX Comments in React

From the React Components & JSX cheat sheet · JSX Fundamentals · verified Jul 2026

JSX Comments

Add comments in JSX code

javascript
function Comments() {
  return (
    <div>
      {/* Single line comment */}
      <h1>Title</h1>
      
      {/* 
        Multi-line
        comment
      */}
      <p>Content</p>
      
      {/* TODO: Add more content */}
      
      {/* Conditional comment
      {false && <p>This won't render</p>}
      */}
    </div>
  )
}

// Regular JS comments work outside JSX
// This is a normal comment
function Component() {
  // Another normal comment
  return <div>Content</div>
}
💡 JSX comments must be inside {/* */}
📌 Regular // comments work outside JSX
⚡ Comments don't appear in rendered HTML
jsxcomments

More React tasks

Back to the full React Components & JSX cheat sheet