Skip to content

Instantly share code, notes, and snippets.

@Nahiduzzaman
Created October 29, 2017 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nahiduzzaman/da35b5ed9f4c027c4b27b3c8d746389a to your computer and use it in GitHub Desktop.
Save Nahiduzzaman/da35b5ed9f4c027c4b27b3c8d746389a to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
count: 0
}
}
incrementCount(){
debugger
this.setState({
count: this.state.count + 1
});
}
decrementCount(){
this.setState({
count: this.state.count - 1
});
}
render() {
return (
<div className="counter">
<h1>{this.state.count}</h1>
<button className="btn" onClick={()=>this.incrementCount()}>Increment</button>
<button className="btn" onClick={()=>this.decrementCount()}>Decrement</button>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment