ReactJS - How to use comments?

后端 未结 13 1771
情深已故
情深已故 2020-12-04 08:17

How can I use comments inside the render method in a React component?

I have the following component:

\'use strict\';
          


        
13条回答
  •  感情败类
    2020-12-04 08:36

    Two Ways to Add Comments in React Native

    1) // (Double Forward Slash) is used to comment only single line in react native code but it can only be used outside of the render block. If you want to comment in render block where we use JSX you need to use the 2nd method.

    2) If you want to comment something in JSX you need to use JavaScript comments inside of Curly braces like {/comment here/}. It is a regular /* Block Comments */, but need to be wrapped in curly braces.

    shortcut keys for /* Block Comments */:

    Ctrl + / on Windows + Linux.
    
    Cmd + / on macOS.
    

提交回复
热议问题