title: How to Update State React Hooks?
body: <p>I'm new on React and I try to learn hooks. I have a probably basic problem but I don't understand why. I determined a hooks state but I couldn't update it.</p>
  <p>My Code:</p>
  <pre><code>function Top(props) {
  
  const [URL, setURL] = useState();
  const [Category, setCategory] = useState();
  
  const { handleSubmit, handleChange } = useFormik({
      initialValues: {},
      onSubmit: values =&gt; {
          clickCrawlButton(values)
      },
  });
  
  const clickCrawlButton = (values) =&gt; {
          fetch(props.baseURL + &quot;/reddit_top&quot;, requestOptionsPost)
          .then(response =&gt; response.json())
          .then(result =&gt; {
              setURL(result) // Why did not it work ?
              props.setInfoText(&quot;Crawl Process Started ...&quot;)
          }).catch(error =&gt; console.log('error', error));
  }
  return (
     &lt;div&gt;
       {URL}
     &lt;/div&gt;
  );
  </code></pre>
  <p>Extra Information:</p>
  <p><a href="https://i.stack.imgur.com/iU8nr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iU8nr.png" alt="I printed to console. Code Detail" /></a></p>
  <p><a href="https://i.stack.imgur.com/YF0Qs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YF0Qs.png" alt="State does not update but result has come." /></a></p>
  <p>I printed to console but although state does not update, result printed to console.</p>