Created
April 14, 2018 10:12
-
-
Save fanux365/4d9de87d321ee30ec1a1683da566f1b9 to your computer and use it in GitHub Desktop.
React.js Little clicker counter
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
import React, { Component } from 'react'; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = {counter: 0}; | |
} | |
CenterButtonClickEvent(e){ | |
this.setState((prevState, props) => ({ | |
counter: prevState.counter + 1 | |
})) | |
} | |
render() { | |
return ( | |
<div> | |
<button style={{"width" : "100%", "height": "97vh"}} onClick={this.CenterButtonClickEvent.bind(this)}>{this.state.counter}</button> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment