title: React. State does not change after change select
body: <p>In the event, I change select element and call the data update method.
  The method takes values from state. But it turns out when the data is updated, state has not been changed yet.
  When you call the data update again, the state has already been updated
  How to do the update correctly?</p>
  <p><strong>React component</strong></p>
  <pre><code>  const [dataList, setdataList] = useState([]);
    const [isLoding, setIsLoading] = useState(false);
    const [minPaid, setMinPaid] = useState(0);
  
    const dataSelectList = [
      { label: &quot;2&quot;, value: &quot;20000000&quot; },
      { label: &quot;3&quot;, value: &quot;30000000&quot; },
      { label: &quot;4&quot;, value: &quot;40000000&quot; },
      { label: &quot;5&quot;, value: &quot;50000000&quot; },
      { label: &quot;10&quot;, value: &quot;100000000&quot; },
    ];
  
    const LoadData = () =&gt; {
      setIsLoading(true);
  
      fetch(&quot;url&quot;, {
        method: &quot;POST&quot;,
        headers: {
          Accept: &quot;application/json&quot;,
          &quot;Content-Type&quot;: &quot;application/json&quot;,
        },
        body: JSON.stringify({
          paid: minPaid,
        }),
      })
        .then((response) =&gt; {
          return response.json();
        })
        .then((data) =&gt; {
          setIsLoading(false);
          if (data.success)
              setdataList(data.list);
        });
    };
  
    
  
    const onChange = (selectedOption) =&gt; {
      setMinPaid(parseInt(selectedOption.value));
      LoadData();
    };
  
    return (
      &lt;div&gt;      
          &lt;Select              
            options={dataList}
            onChange={onChange.bind(this)}
          /&gt;          
      &lt;/div&gt;
    );
  </code></pre>