React.jsx comments


#1

is it ok to have server.jsx

// this is comment

or must it be

{/* this is a comment */}


#2

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


#3

Hi @hedward1

// var x = 5

this is not ignored in ReactJS .jsx file?


#4

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


#5

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


#6

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


#7

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.