There are a bunch of reducers under src/state/reducers. Whilst they seem to be working fine, they don't seem to align with the redux/react docs entirely.
There are 3 areas where improvement could be done:
Remove unnecessary state = * assignment. We shouldn't mutate the state.
_.merge mutates the state. It should be merge({}, state, action.payload) (Caution: This is rather expensive. Maybe immutable-ops#deepMerge is an option)
Remove unnecessary return state, as the reducer takes care of it. Only in cases where we want action.payload to replace the state we should return action.payload.
Further thoughts:
Maybe, the reducers could be a little more detailed. Just to avoid to have to deal with functionalities like _.merge. If we would know where the change needs to be applied, we could probably get rid of the merge functionality. This would help the state (and any re-render).
There are a bunch of reducers under
src/state/reducers
. Whilst they seem to be working fine, they don't seem to align with the redux/react docs entirely.There are 3 areas where improvement could be done:
state = *
assignment. We shouldn't mutate the state._.merge
mutates the state. It should be merge({}, state, action.payload) (Caution: This is rather expensive. Maybe immutable-ops#deepMerge is an option)return state
, as the reducer takes care of it. Only in cases where we wantaction.payload
to replace the state we shouldreturn action.payload
.Further thoughts: Maybe, the reducers could be a little more detailed. Just to avoid to have to deal with functionalities like
_.merge
. If we would know where the change needs to be applied, we could probably get rid of the merge functionality. This would help the state (and any re-render).