Skip to content Skip to sidebar Skip to footer

Recommended Use Of Comments Style In Meteor When Using React

I just want some clarity on correct comments usage when using React in Meteor. Do I have to use the {/* React comment */} style everywhere in my code? I have found that the normal

Solution 1:

That is the only way to put comment inside JSX tag. You are not allowed to use regular XML comment tag i.e. <!-- This doesn't work! --> and react team has no plan of adding another style of comment.

Outside JSX tag, you can use regular javascript comment.

//comment/*
    or comment
*/

Read more.

Example:

classCompextendsReact.Component {
    componentDidMount(){
        // you can use regular js comment here/* 
             also multiline comment
        */
    }

    render(){
        return (
            <div>
                {/* but inside JSX, you must use comment style like this */}
                <span>Content</span></div>
        );
    }
}

Solution 2:

I would also add to the above answer by Niyoko Yuliawan that this works not just in React but also in Blaze. Blaze doesn't accept // commenting in the Javascript files but does accept the /* */ start and end tags. As such the above answer may be more general to Meteor than isolated to React.

Post a Comment for "Recommended Use Of Comments Style In Meteor When Using React"