react-redux store not updating within onClick function
<p>I'm experiencing this weird issue where my react-redux store is updating, but is not updating within the function that calls the actions.</p>

<p><code>this.props.active</code> is <code>undefined</code>, then I set it to an integer with <code>this.props.actions.activeSet(activeProc)</code>, but it remains <code>undefined</code> and enters the next if condition.</p>

<p>I know my app is working because everything else works with <code>this.props.active</code> having the correct value.</p>

<p>Is this supposed to happen?</p>

<p><strong>edit:</strong></p>

<p>After doing some testing, it appears that the state remains the same inside the onClick function.</p>

<p>All calls to <code>console.log(this.props)</code> made within the onClick function show no change to the state, but adding <code>setTimeout(() =&gt; {console.log(this.props)}, 1)</code> at the end to test shows that the state is being updated.</p>

<p>Other parts of the app are working as intended, with state changes applied immediately.</p>

<p>But I still don't understand what is going on.</p>

<p><strong>Component function code</strong></p>

<pre><code>() =&gt; {
    console.log(this.props.active); // undefined
    if (this.props.active === undefined &amp;&amp; this.props.readyQueue.length &gt; 0) {
        let activeProc = this.props.readyQueue[0];
        this.props.actions.readyPop();
        this.props.actions.activeSet(activeProc); // set to an integer
        this.props.actions.execStateSet("Running");
    }

    console.log(this.props.active); // still remains undefined
    if (this.props.active === undefined) {
        this.props.actions.execStateSet("Idle");
    }
}

function mapStateToProps(state, props) {
    return {
        active: state.ProcessReducer.active,
    };
}
</code></pre>

<p><strong>Action code</strong></p>

<pre><code>export const activeSet = (procId) =&gt; {
    return {
        type: 'ACTIVE_SET',
        procId
    }
}
</code></pre>

<p><strong>Reducer code</strong></p>

<pre><code>case 'ACTIVE_SET':
    return Object.assign({}, state, {
        active: action.procId
    });
</code></pre>