Skip to content

Instantly share code, notes, and snippets.

@fdjones
Created February 8, 2018 16:29
Show Gist options
  • Save fdjones/9d94905b0c69dc88c6b05d2434154b6d to your computer and use it in GitHub Desktop.
Save fdjones/9d94905b0c69dc88c6b05d2434154b6d to your computer and use it in GitHub Desktop.
class Task extends React.Component {
constructor(props: Object) {
super(props);
this.state = { isInProgress: true };
this.updateStatus = this.updateStatus.bind(this);
}
updateStatus = function () {
this.setState({ isInProgress: !this.state.isInProgress });
}
render() {
return (
<div className="tasks-wrapper">
{this.props.tasks.map(task => (
<div className="task-container" key={task.ID}>
<h2>{task.title}</h2>
<h3 className="status" onClick={this.updateStatus}>
{this.state.isInProgress ? 'In Progress' : 'Done'}
</h3>
<h4>{task.details}</h4>
</div>
))}
</div>
)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment