Skip to content

Instantly share code, notes, and snippets.

@Louiefigz
Created June 11, 2017 13:17
Show Gist options
  • Save Louiefigz/e820d84e436c5bd1aa092b82748e87e2 to your computer and use it in GitHub Desktop.
Save Louiefigz/e820d84e436c5bd1aa092b82748e87e2 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(
this.state.complete ?
<div>
<li>{this.props.task}</li>
Mission complete
</div>
:
<div>
<li>{this.props.task}</li>
<button onClick={ (event)=> this.handleClick(event) }>complete</button>
<br></br>
</div>
)
}
}
export default Todo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment