Skip to content

Instantly share code, notes, and snippets.

@fanux365
Created April 14, 2018 10:12
Show Gist options
  • Save fanux365/4d9de87d321ee30ec1a1683da566f1b9 to your computer and use it in GitHub Desktop.
Save fanux365/4d9de87d321ee30ec1a1683da566f1b9 to your computer and use it in GitHub Desktop.
React.js Little clicker counter
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