Easy-peasy: getStoreState returns stale state

Created on 27 Mar 2019  路  2Comments  路  Source: ctrlplusb/easy-peasy

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?

bug

Most helpful comment

Fixed in v2.1.2

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vincentjames501 picture vincentjames501  路  6Comments

pitops picture pitops  路  4Comments

ifyoumakeit picture ifyoumakeit  路  5Comments

raul-madrigal picture raul-madrigal  路  3Comments

giacomorebonato picture giacomorebonato  路  5Comments