Skip to content

Instantly share code, notes, and snippets.

@rcdexta
Created October 9, 2018 00:28
Show Gist options
  • Save rcdexta/d32f9c2e81199ca58990517899d3a2ef to your computer and use it in GitHub Desktop.
Save rcdexta/d32f9c2e81199ca58990517899d3a2ef to your computer and use it in GitHub Desktop.
TodoListItem
class TodoListItem extends React.Component {
static propTypes = {
item: PropTypes.object,
removeItem: PropTypes.func,
markTodoDone: PropTypes.func
}
onClickClose = () => {
const {index, removeItem} = this.props;
removeItem(index);
};
onClickDone = () => {
const {index, markTodoDone} = this.props;
markTodoDone(index);
};
render() {
const {item} = this.props;
const todoClass = item.done ? "done" : "undone";
return (
<tr data-testid={`todoItem${item.index}`}>
<td className={todoClass}>
<span data-testid="markAsCompleted" className="glyphicon glyphicon-ok icon" aria-hidden="true" onClick={this.onClickDone}/>
{item.value}
<span data-testid="markAsDeleted"className="glyphicon glyphicon-remove-sign close" aria-hidden="true" onClick={this.onClickClose}/>
</td>
</tr>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment