title: Passing Variable to setState
body: <p>I am new to react. In my program, the user is asked to click on a button, and according to that button, the state is changed.</p>
  
  <p>This is the rendered section:</p>
  
  <pre><code>&lt;button onClick={this.togglePage(2)}&gt;Click Here&lt;/button&gt;
  </code></pre>
  
  <p>This is the part before:</p>
  
  <pre><code>  constructor(props) {
      super(props);
      this.togglePage = this.togglePage.bind(this);
  
      this.state = {
        currentpage: 1,
      };
    }
    togglePage(page) {
      this.setState({
        currentpage: page,
      });
    }
  </code></pre>
  
  <p>Is the way I am passing  a value here correct? I am getting an error saying "Maximum Update Depth Exceeded"</p>