React.jsx comments

is it ok to have server.jsx

// this is comment

or must it be

{/* this is a comment */}

They must be {/* this is a comment */} for .jsx

Hi @hedward1

// var x = 5

this is not ignored in ReactJS .jsx file?

No. It’s not. As @hedward1 just stated.

Hi Simon/@hedward1

Are you sure?

in my server.js/sample.jsx:

console.log('testpoint'); 

testpoint gets printed on console

When I commented out as

//console.log('testpoint'); 

testpoint does not get printed

jsx is just javascript, so both // and /* …*/ will work.

From Facebook’s JSX in depth: “It’s easy to add comments within your JSX; they’re just JS expressions. You just need to be careful to put {} around the comments when you are within the children section of a tag.”

To clarify, if you are in the children section of a tag you need the curly braces. Otherwise, I have just used /* … */ as a convention. You do seem to be correct that // will work so long as it is not in a child section of a tag and single line.