Created
February 8, 2018 16:29
-
-
Save fdjones/9d94905b0c69dc88c6b05d2434154b6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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