title: React: Maximum update depth exceeded
body: <p>I am getting this error when I run my code. </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>And here's the code . it's referencing.</p>
  
  <pre><code>  69 | }
    70 | 
    71 | addQuestion = () =&gt; {
  &gt; 72 |   this.setState({numQuestions: this.state.numQuestions + 1});
    73 |  }
    74 | 
    75 | render() {
  
    131 | &lt;div className="field"&gt;
    132 |     &lt;div className="endButtons"&gt;
    133 |       &lt;button id="addQuestionButton"
  &gt; 134 |         onClick={this.addQuestion()}&gt;Add Question&lt;/button&gt;
    135 |       &lt;input
    136 |         type="submit"
    137 |         value="Submit"
  
     5 | import App from './App';
     6 | import registerServiceWorker from './registerServiceWorker';
     7 | 
  &gt;  8 | ReactDOM.render(&lt;App /&gt;, document.getElementById('root'));
     9 | registerServiceWorker();
    10 | 
    11 | 
  </code></pre>
  
  <p>I set my stuff up the way the articles on the actual React site said to and it "came" with this neat console type thing, that's where I came up with the above code. I'm very new to React, JSX, and Javascript (and just programing in general) and I don't really understand what this means so if you could also explain a little that would be awesome.</p>
  
  <p>Thanks!</p>