You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As redcr()'s signature accepts a void-returning function, it might be expected that this will work. However, the output is
constreducer=(state)=>{if(val==3){state={ ...state,str: 'abc'};return;// <<< should be return state;}state={ ...state,str: 'def'};returnstate;};
The first branch will end up returning undefined. A workaround exists: the author can specify return state; rather than return; but maybe that's unintuitive since the function is supposed to be void-returning.
It might be desirable to return early within a reducer, for example
As
redcr()
's signature accepts a void-returning function, it might be expected that this will work. However, the output isThe first branch will end up returning undefined. A workaround exists: the author can specify
return state;
rather thanreturn;
but maybe that's unintuitive since the function is supposed to be void-returning.Somewhat related to #14
The text was updated successfully, but these errors were encountered: