title: How to increase/decrease count on click of same button in Js/ReactJs
body: <p>I want to increment/decrement counter based on button click. 
  Scenario: 
  There is an initial value on the button- say: 5
  When a user clicks on the button, it increments to +1 - o/p: 6
  however when the user clicks again on the button it, it'll reduce to 5 again.
  this case I dont have 2 buttons- inc and dec to increase/decrease the count.</p>
  
  <p>code:</p>
  
  <pre><code>class Hello extends React.Component {
  constructor() {
     super()
     this.state = {
       count: 10,
  
     }
   }
   getCount( c ) {
  
      const clicked = this.state.clicked
  if(c == 1){
    this.setState({count: this.state.count +1, clicked: true});
  } else {
    this.setState({count: this.state.count -1})
  }
  
    }
    render() {
      return  &lt;div&gt;
                      &lt;button onClick={this.getCount.bind(this, 1)}&gt; click me for increase &lt;/button&gt;
                      &lt;button onClick={this.getCount.bind(this, 0)}&gt; click me for decrease &lt;/button&gt;
                      &lt;div&gt;&lt;h1&gt;{this.state.count}&lt;/h1&gt;&lt;/div&gt;
  
                       &lt;/div&gt;;
    }
  }
  
  ReactDOM.render(
    &lt;Hello name="World" /&gt;,
    document.getElementById('root')
  );
  </code></pre>