score:31

Accepted answer

is it possible that component c were rerendered when r1 is executed but before r2 is executed?

no, it is not possible if you use a single store like redux docs suggest.

in redux, you combine reducers with combinereducers(). this means that from redux’s point of view, there is only a single reducer, and it is synchronous. sure, it calls your two reducers, but the redux store only begins notifying subscribers after it gets the new state value from its root reducer, so it is guaranteed that all your reducers have already been executed by the time the views are notified.

score:0

redux actions are dispatched synchronously, so all side effects of an action will occur immediately after the action is dispatched. this means your component will only re-render once since react doesn't re-render immediately on state change (it seems to instead defer until the next event loop or animation frame) even if you call setstate multiple times.

you can define the order of dispatch by simply changing the order you're calling store.dispatch. call r1.dispatch first if you want all side effects of r1 changing to happen first.


Related Query

More Query from same tag