import React, { PropTypes, Component } from 'react'; class CommentItem extends Component{ constructor() { super(); ['showReply', 'cancelReply', 'replyCallback', 'showEdit', 'cancelEdit', 'editCallback'].forEach(methodName => {this[methodName] = this[methodName].bind(this)}); this.state = { showReply: false, showEdit: false }; } showReply(event) { event.preventDefault(); this.setState({showReply: true}); } cancelReply(event) { event.preventDefault(); this.setState({showReply: false}); } replyCallback() { this.setState({showReply: false}); } showEdit(event) { event.preventDefault(); this.setState({showEdit: true}); } cancelEdit(event) { event.preventDefault(); this.setState({showEdit: false}); } editCallback() { this.setState({showEdit: false}); } renderComment() { const htmlBody = {__html: this.props.comment.htmlBody}; return (
) } renderReply() { ({CommentNew} = Telescope.components); return (
Cancel
) } renderEdit() { ({CommentEdit} = Telescope.components); return ( ) } renderActions() { return ( ) } render() { return (
{this.state.showEdit ? this.renderEdit() : this.renderComment()} {this.renderActions()}
{this.state.showReply ? this.renderReply() : ""}
) } } CommentItem.propTypes = { comment: React.PropTypes.object.isRequired, // the current comment currentUser: React.PropTypes.object, // the current user } module.exports = CommentItem;