Tuesday, March 3, 2020

How to comment in React JSX

We cannot use HTML comments inside of JSX because it thinks they are real DOM Nodes:

render() {
  return (
    <div>
      <!-- This doesn't work! -->
    </div>
  )
}

We can use regular /* Block Comments */, but this need to be wrapped in curly braces:

{/* A JSX comment */}

1 comment:

  1. Nice Blog,
    The details that you mentioned in this blog regarding React js development.
    I was searching for the best react js development company and found your blog.
    Thanks for sharing such a great blog.
    Synsoft Global

    ReplyDelete

Popular Posts