title: Maximum update depth exceeded. This can happen when a component repeatedly calls setState
body: <p>I want to invoke a method but in meantime it give me an error:</p>
  
  <blockquote>
    <p>Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.</p>
  </blockquote>
  
  <p><strong>Function Declaration</strong></p>
  
  <pre><code>datahandler= (val1,val2) =&gt; {
      this.setState(
        {
          dataNew:
            this.state.dataNew=== {val1} ? {val2} : {val1}
        },
        () =&gt; {
          this.getNew();
        }
      );
    };
  </code></pre>
  
  <p><strong>Function Calling</strong></p>
  
  <pre><code>&lt;Table.HeaderCell onClick={this.datahandler('name asc','name desc')}&gt;
    Click Me to Call
  &lt;/Table.Headercell&gt;
  </code></pre>