title: I get unlimited amount of GET 404 Error if I try to setState in axios catch error in React
body: <p>I'm trying to setState inside a catch promise in Axios React, It works but I get an unlimited amount of request and 404 error.</p>
  <pre><code>class Search extends Component {
    state = {
      notFound: false,
      dataResult: &quot;&quot;,
    };
  
    componentDidUpdate() {
      axios
        .get(&quot;url&quot;)
        .then((resp) =&gt; {
          this.setState({ dataResult: resp.data });
        })
        .catch((err) =&gt; {
          if (err.response.status === 404) {
            this.setState({ notFound: true });
          }
        });
    }
  
    render() {
      return (
        &lt;div&gt;
          {this.state.notFound ? &lt;div&gt;NOTFOUND&lt;/div&gt; : null}
        &lt;/div&gt;
      );
    }
  }
  
  </code></pre>
  <p>console result(URL is an API):</p>
  <p>GET &quot;url&quot; 404 (Not Found)
  GET &quot;url&quot; 404 (Not Found)
  GET &quot;url&quot; 404 (Not Found)
  ...</p>