title: Why does my fetch query run multiple times in my React component
body: <p>I have a fetch query that is running multiple times. I am using react JS. Why is this happening? How can I prevent the query from running multiple times?</p>
  <p>Here is my code</p>
  <pre><code>const MyComponent = () =&gt; {
    const [tokenslist, setTokensList] = useState([])
      
    fetch(&quot;http://localhost:81/getTokensList&quot;)
     .then(response =&gt; response.json())
     .then(data =&gt; {
         setTokensList(data);
         console.log(&quot;TOKENS&quot;, tokenlist);
         query(tokenslist)
     });
  
     ...
  }
  </code></pre>