Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducers - handle state gracefully #37

Open
tschaka1904 opened this issue Oct 5, 2022 · 1 comment
Open

Reducers - handle state gracefully #37

tschaka1904 opened this issue Oct 5, 2022 · 1 comment

Comments

@tschaka1904
Copy link

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).

@tschaka1904
Copy link
Author

This should mostly be addressed in #38 #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant