Hi,
I've been looking around to try to find out more about the "dispatch / render" flow and can not find anything relevant yet.
My question is: when I do 2 dispatchsequentially such as:
dispatch({type: ACTION_1});
dispatch({type: ACTION_2});
Are we sure that the 2 actions will be processed before the next rendering cycle occurs?
Could it be that on the next rendering cycle, only ACTION_1 has been processed then ACTION_2 is processed on a later rendering cycle?
In other words, from the react perspective, is doing:
dispatch({type: ACTION_1});
dispatch({type: ACTION_2});
equivalent to:
dispatch({type: ACTIONS: payload: [ACTION_1, ACTION2]});
In a small demo, it seems that it doesn't matter:
https://codesandbox.io/s/tzp0s (see the console messages)
In my larger react app, it seems that often time there is a render cycle between 2 consecutive dispatch.
Is it considered an anti-pattern to do 2 dispatch sequentially and should we instead do 1 dispatch with the content of the 2 dispatch combined?
Thank you!
Hi,
I've been looking around to try to find out more about the "dispatch / render" flow and can not find anything relevant yet.
My question is: when I do 2
dispatchsequentially such as:Are we sure that the 2 actions will be processed before the next rendering cycle occurs?
Could it be that on the next rendering cycle, only
ACTION_1has been processed thenACTION_2is processed on a later rendering cycle?In other words, from the react perspective, is doing:
In a small demo, it seems that it doesn't matter:
https://codesandbox.io/s/tzp0s (see the console messages)
In my larger react app, it seems that often time there is a render cycle between 2 consecutive
dispatch.Is it considered an anti-pattern to do 2
dispatchsequentially and should we instead do 1dispatchwith the content of the 2dispatchcombined?Thank you!