title: Antipattern error when react child component updating parent
body: <p>I am getting the error <code>Uncaught RangeError: Maximum call stack size exceeded</code>. How do I eliminate this recursive function in my child (<code>Typewriter</code>) component? I believe I am getting this error because I am calling a function constantly in the ComponentWillUpdate() ? How do I fix this? I thought that by adding in the if condition, this should be fixed?
   Please see the snippet below. Thanks!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Parent extends React.Component {
    constructor(props) {
      super(props);
      this.state = {
        typing: true,
      };
      this.interval = null;
      this.handleTyping = this.handleTyping.bind(this);
    }
  
    handleTyping(doneTyping) {
      if (doneTyping) {
        this.setState({ typing: !this.state.typing });
      }
    }
  
    render() {
      return (
        &lt;div&gt;
          &lt;h3&gt;{this.state.typing ? "TRUE" : "FALSE"}&lt;/h3&gt;
          &lt;Typewriter text={"typewriter_testing"} typeSpeed={50} handleTyping={this.handleTyping}/&gt;
        &lt;/div&gt;
      );
    }
  }
  
  class Typewriter extends React.Component {
    constructor() {
      super();
      this.state = {
        finalText: '',
        doneTyping: false,
      }
      this.typeWriter = this.typeWriter.bind(this);
    }
  
    typeWriter(text, n) {
      if (n &lt; (text.length)) {
        if (n + 1 == (text.length)) {
          let j = text.substring(0, n+1);
          this.setState({ finalText: j, doneTyping: !this.state.doneTyping });
          n++;
        }
        else {
          let k = text.substring(0, n+1) + '|';
          this.setState({ finalText: k });
          n++;
        }
        setTimeout( () =&gt; { this.typeWriter(text, n) }, this.props.typeSpeed );
      }
    }
  
    componentDidMount() {
      this.typeWriter(this.props.text, 0);
    }
  
    componentWillUpdate(nextProps, nextState) {
      if (nextState.doneTyping) {
        nextProps.handleTyping(nextState.doneTyping);
      }
    }
  
    render() {
      return (
        &lt;div&gt;
          { this.state.finalText }
        &lt;/div&gt;
      );
    }
  }
  
  ReactDOM.render(&lt;Parent /&gt;, app);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;div id="app"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>