title: how to update state and take a decision on updated state in react native
body: <p>I am using the Picker component in my app. And there is list view on the screen. Based on the selected value of the Picker, list view gets updated. Here is the code</p>
  
  <pre><code>&lt;Picker style={{ flex: 0.3, marginTop: -10 }}
    selectedValue={this.state.helpModel.needyType}
    onValueChange={(itemValue, itemIndex) =&gt; {
      this.setState((prevState) =&gt; {
        return { helpModel: { needyType: itemValue, helpStatus: prevState.helpModel.helpStatus } }
      });
      this.getNeedies(this.state.helpModel);
    }}&gt;
    {this.state.helpCategory.map((data, index) =&gt; {
      return (
        &lt;Picker.Item key={data.id} label={data.title} value={data.value} /&gt;
      );
    })}
  &lt;/Picker&gt;
  </code></pre>
  
  <p>I have used state variable (<code>this.state.helpModel.needyType</code>) to bind the <code>selectedValue</code> of the picker and on the <code>onValueChange</code> I am updating the state variable. Then a method is called based on the <code>this.state.helpModel</code> that will get the list data and update the list view. But <code>helpModel</code> is not getting the update immediately so it retains the previous values for a time but in that time <code>getNeedies</code> method is called and based on the previous value data is requested.  </p>
  
  <p>May be this is because <code>setState</code> is of async behaviour. I have solved this using to call <code>getNeedies</code> method after some 2-3 seconds using <code>setTimeout</code>. But is there any better or elegant way to do the same? May be <code>.then</code> like in <code>promises</code>? </p>
  
  <p>I have just started with React Native, so please ignore if this is too basic to ask.</p>