Created
September 5, 2018 07:03
-
-
Save codingnninja/db92f4f12e42ca87b3b23229b60b4389 to your computer and use it in GitHub Desktop.
This file contains 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 Vote extends React.Component { | |
constructor(){ | |
super(); | |
this.state = { | |
message: "Click on an image to vote" | |
}; | |
this.voteForBuhari = this.voteForBuhari.bind(this); | |
this.voteForFela = this.voteForFela.bind(this); | |
this.voteForSowore = this.voteForSowore.bind(this); | |
} | |
voteForBuhari() { | |
this.setState({ | |
message: "You just voted for Mohammadu Buhari" | |
}); | |
} | |
voteForFela() { | |
this.setState({ | |
message: "You just voted for Fela Durotoye" | |
}); | |
} | |
voteForSowore() { | |
this.setState({ | |
message: "You just voted for Sowore" | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<div class="row container center-block"> | |
<h1>{this.state.message}!</h1> | |
<div class="col-sm-4"> | |
<img | |
src="assets/images/buhari.jpg" | |
onClick={this.voteForBuhari} | |
/> | |
</div> | |
<div class="col-sm-4"> | |
<img | |
src="assets/images/fela.jpg" | |
onClick={this.voteForFela} | |
/> | |
</div> | |
<div class="col-sm-4"> | |
<img | |
src="assets/images/sowore.jpg" | |
onClick={this.voteForSowore} | |
/> | |
</div> | |
</div> | |
</div> | |
); | |
} | |
} | |
ReactDOM.render( | |
<Vote/>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment