JSX allows us to use comments as it allows us to use JavaScript expressions. Comments in JSX begins with /* and ends with */. We can add comments in JSX by wrapping them in curly braces {} just like we did in the case of expressions.
When writing comments, we need to put curly brackets {} when we want to write comment within children section of a tag. It is a good practice to always use {} when writing comments, since we want to be consistent when writing the app.
import React from ‘react’;
class App extends React.Component {
render() {
return (
<div>
<h1>Header</h1>
{//End of the line Comment…}
{/*Multi line comment…*/}
</div>
);
}
}
export default App;