title: Understanding React useEffect functions
body: <p>I'm trying to understand how to call Flask APIs in React. Currently, I have this function defined in the <code>App()</code> function within my <code>App.js</code> file:</p>
  <pre class="lang-js prettyprint-override"><code>useEffect(() =&gt; {
      fetch('/').then(response =&gt;
        response.json().then(data =&gt; {
          console.log(data)
        })
        )
    }, [])
  </code></pre>
  <p>I don't have much experience with JavaScript and I know that React's JSX can be confusing, so I'm hoping someone can clarify my understanding of this function.</p>
  <h3>What I think this means:</h3>
  <ol>
  <li>On startup (indicated by []), call this JS function (as indicated by the {} brackets) that has no input as indicated by the first set of empty parentheses ()</li>
  <li>From the flask application, call the endpoint with the route indicated</li>
  <li>Take this response (which we have <em>named</em> response?), and run the <code>json()</code> method to read the body as json</li>
  <li>The result (which we have <em>named</em> data?) is then logged in the console. The curly brackets here again denoting that this is JS(X) code</li>
  </ol>
  <p>Is this correct? Any feedback is much appreciated!</p>