You can read about this in React documentation , but basically there are 4 different types.
I did a sample jsFiddle here: link
The code is:
var Span = React.createClass({
render: function() {
return (
<span style={{color: this.props.color}}>
{this.props.text}
</span>
);
}
});
var Hello = React.createClass({
render: function() {
return (<div>
<Span {...this.props} text={'Hello'} />
{/* comentário entre componentes */}
<Span {...this.props} text={' World!'} />
</div>);
}
});
ReactDOM.render(
// comentário ao estilo JavaScript
< Hello /* comentário dentro do componente */ name="World" /*
comentários de multiplas linhas funcionam também!
*/ color={'blue'}
/> ,
document.getElementById('container')
);
# 1 - Component comments:
Within JSX, between components the syntax is {/* texto aqui */}
. The reason for the {}
keys is to interpret as JavaScript and then know how to comment.
# 2 - Comments off and before components:
render: function() {
return (
// comentário antes do componente contentor...
<div>
# 3 - comments inside the component tags on the same line:
<Hello /* comentário dentro do componente */ name="World" />
# 4 - comments within component tags in multiple lines:
<Hello name="World"
/*
comentários de multiplas linhas funcionam também!
*/
color={'blue'}
/>
link