title: React JS which button is clicked how many times?
body: <p>I have 2 buttons and 1 h1 I need to count how many times the button is clicked and display the button name with no. of count it clicked in h1 with the name of the button. Right now I am getting the name of button correctly but not able to display the click count for the button. please help</p>
  
  <pre><code>import React, { Component, Fragment } from 'react'
  import ReactDOM from 'react-dom'
  
  export default class App extends Component {
    state={
      button:"",
      countClick:0
    }
  
  buttonClick=(e)=&gt;{
    e.preventDefault();
    this.setState({button:e.target.name, countClick:this.state.countClick+1});
  }
  
    render() {
      return (
        &lt;Fragment&gt;
          &lt;h1&gt;
            {this.state.button} clicked {this.state.countClick} times
          &lt;/h1&gt;
          &lt;button name="Button 1" type="button" onClick={this.buttonClick}&gt;Button 1&lt;/button&gt;
          &lt;button name="Button 2" type="button" onClick={this.buttonClick}&gt;Button 2&lt;/button&gt;
        &lt;/Fragment&gt;
      )
    }
  }
  
  
  ReactDOM.render(&lt;App /&gt;,document.getElementById('root'));
  </code></pre>
  
  <p>Thank You </p>