As given in docs,
handler (Function, required)
The handler thunk to be executed after the target action is fired successfully.
So, I was under the impression that, once target action is completed successfully, the listener is executed.
But getStoreState does not return the modified state by the target action.
The code is here
Expected behavior :
counter2 should be always counter1 + 100
Actual behavior
after pressing button,
counter2 is always counter1 + 100 - 1 (or in other words, it is stale value of counter1 + 100)
In console logs as well, 'in listener' is logged before 'in increment'. Where as listener is expected to execute after increment.
Is this by design?
The listener is firing prior to the action, hence the stale state. This must be a bug.
Thanks for the demo. Really helps me quickly debug this. 馃憤
Fixed in v2.1.2
Most helpful comment
Fixed in v2.1.2