ReactJS - How to use comments?

后端 未结 13 1757
情深已故
情深已故 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:49

    So within the render method comments are allowed but in order to use them within JSX, you have to wrap them in braces and use multi-line style comments.

    <div className="dropdown">
        {/* whenClicked is a property not an event, per se. */}
        <Button whenClicked={this.handleClick} className="btn-default" title={this.props.title} subTitleClassName="caret"></Button>
        <UnorderedList />
    </div>
    

    You can read more about how comments work in JSX here

    0 讨论(0)
提交回复
热议问题