Skip to content

Instantly share code, notes, and snippets.

@Louiefigz
Created June 11, 2017 16:44
Show Gist options
  • Save Louiefigz/12d3861dbd653e712ea8f5a9ab0d9702 to your computer and use it in GitHub Desktop.
Save Louiefigz/12d3861dbd653e712ea8f5a9ab0d9702 to your computer and use it in GitHub Desktop.
import React from 'react';
class Todo extends React.Component{
constructor(){
super();
this.state={
complete: false
}
}
handleClick(e){
e.preventDefault();
this.setState({
complete: true
})
}
render(){
return(
<div>
<li>{this.props.task}</li>
{this.state.complete ? undefined : <button onClick={ (event)=> this.handleClick(event) }>complete</button>}
<br></br>
{this.state.complete ? "complete" : "mission not complete"}
</div>
)
}
}
export default Todo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment