pitaya-launcher/js/components/app-item.jsx

29 lines
720 B
JavaScript

var React = require('react');
module.exports = React.createClass({
propTypes: {
item: React.PropTypes.object.isRequired,
itemPath: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.arrayOf(React.PropTypes.number)
]).isRequired,
onItemClick: React.PropTypes.func.isRequired,
},
_onItemClick: function(evt) {
evt.preventDefault();
this.props.onItemClick(evt, this.props.itemPath, this.props.item);
},
render: function() {
return (
<li className="app-item" onClick={this._onItemClick}>
<img className="app-icon" src={this.props.item.icon} />
<span className="app-label">{this.props.item.label}</span>
</li>
);
}
});