Skip to content

Reducers - handle state gracefully #37

@tschaka1904

Description

@tschaka1904

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:

  1. Remove unnecessary state = * assignment. We shouldn't mutate the state.
  2. _.merge mutates the state. It should be merge({}, state, action.payload) (Caution: This is rather expensive. Maybe immutable-ops#deepMerge is an option)
  3. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions