問題:
How can I use comments inside the render
method in a React component?如何在 React 組件的render
方法中使用註釋?
I have the following component:我有以下組件:
'use strict';
var React = require('react'),
Button = require('./button'),
UnorderedList = require('./unordered-list');
class Dropdown extends React.Component{
constructor(props) {
super(props);
}
handleClick() {
alert('I am click here');
}
render() {
return (
<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>
)
}
}
module.exports = Dropdown;
My comments are showing up in the UI.我的評論顯示在用戶界面中。
What would be the right approach to apply single and multiple line comments inside a render method of a component?在組件的渲染方法中應用單行和多行註釋的正確方法是什麼?
解決方案:
參考一: https://stackoom.com/question/255kv參考二: ReactJS - How to use comments?