DEV Community

skptricks
skptricks

Posted on

How to comment in React JSX

Post Link : https://www.skptricks.com/2018/08/how-to-comment-in-react-jsx.html

This tutorial explains how to perform comment in react js application. React uses JSX, it is a XML-like syntax extension to ECMAScript without any defined semantics. It's NOT intended to be implemented by engines or browsers.

How to comment in React JSX

Point to remember, while adding comment in react application :

  1. You can use regular /* Block Comments /, but they need to be wrapped in curly braces:
    {/
    A JSX comment */}

  2. For multi-line comment, you can use below syntax :
    {/*
    Multi
    line
    comment
    */}

  3. You can't just use HTML comments inside of JSX because the compiler will think that they are real DOM Nodes. React developers has stated they do not plan to add regular JS commenting to JSX.
    Bad Practice.
    render() {
    return (

    )
    }

Read More...

Top comments (0)