ensl_gathers/lib/react/event.jsx
2016-01-02 21:32:26 +00:00

26 lines
538 B
JavaScript

const Events = React.createClass({
propTypes: {
events: React.PropTypes.array.isRequired
},
getTime(timeString) {
return (new Date(timeString)).toTimeString().match(/^[\d:]*/)[0];
},
render() {
let events;
if (this.props.events.length) {
events = this.props.events.map(event => {
return `${this.getTime(event.createdAt)} ${event.description}`;
}).join("\n");
} else {
events = <tr><td>Listening for new events...</td></tr>
}
return (
<pre className="events-panel">
{events}
</pre>
);
}
});