title: React setState not updating state immediately
body: <p>I have to select the dropdown twice to update the details.</p>
  <pre><code>     &lt;Dropdown
          onSelect={(e) =&gt; {
            if (e === &quot;YES&quot;) {
              this.setState({
                BasePlantsSiteHire: &quot;&quot;,
              });
            } else if (e === &quot;NO&quot;) {
              this.setState({
                BasePlantsSiteHire: &quot;N&quot;,
              });
            } else if (e === &quot;ONLY&quot;) {
              this.setState({
                BasePlantsSiteHire: &quot;Y&quot;,
              });
            }
            this.componentDidMount();
            console.log(
              &quot;Status Updated: &quot;,
              this.state.BasePlantsSiteHire
            );
          }}
        &gt;
          &lt;Dropdown.Toggle style={{ background: &quot;none&quot;, border: &quot;none&quot; }}&gt;
            &lt;CIcon name=&quot;cil-settings&quot; /&gt;
          &lt;/Dropdown.Toggle&gt;
          &lt;Dropdown.Menu className=&quot;pt-0&quot; placement=&quot;bottom-end&quot;&gt;
            &lt;Dropdown.Item
              eventKey=&quot;YES&quot;
              name=&quot;YES&quot;
              key=&quot;YES&quot;
              value=&quot;YES&quot;
            &gt;
              SubHire Include
            &lt;/Dropdown.Item&gt;
            &lt;Dropdown.Item eventKey=&quot;NO&quot; name=&quot;NO&quot; key=&quot;NO&quot; value=&quot;NO&quot;&gt;
              SubHire Exclude
            &lt;/Dropdown.Item&gt;
            &lt;Dropdown.Item
              eventKey=&quot;ONLY&quot;
              name=&quot;ONLY&quot;
              key=&quot;ONLY&quot;
              value=&quot;ONLY&quot;
            &gt;
              SubHire Only
            &lt;/Dropdown.Item&gt;
          &lt;/Dropdown.Menu&gt;
        &lt;/Dropdown&gt;
  </code></pre>
  <p>My problem is that when I call the select dropdown it is not updating immediately, Need to select twice to get the action and console.log the state.</p>
  <p><a href="https://i.stack.imgur.com/esdiu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/esdiu.png" alt="enter image description here" /></a></p>