title: How to stop executing a command the contains useState?
body: <p>This is my code which sends a GET request to my backend (mySQL) and gets the data. I am using useState to extract and set the response.data .</p>
  <pre><code>const baseURL = 'http://localhost:5000/api/user/timesheet/13009';
  
  const [DataArray , setDataArray] = useState([]);
  
  
  axios.get(baseURL).then( (response)=&gt;{
      setDataArray(response.data);
  });
  </code></pre>
  <p>But useState keeps on sending the GET request to my server and I only want to resend the GET request and re-render when I click a button or execute another function.</p>
  <p><a href="https://i.stack.imgur.com/enDZT.png" rel="nofollow noreferrer">Server Terminal Console</a></p>
  <p>Is there a better way to store response.data and if not how can I stop automatic re-rendering of useState and make it so that it re-renders only when I want to.</p>