I have been using a simple helper to simplify and reduce boilerplate for setting up reducers in Redux.
Lets take a look at a default switch reducer:
What could be improved:
Take a look at the following helper that I’ve using in most of my projects which simplifies the reducers:
Now lets convert the switch reducer to our new optimized reducer:
So as you can see we cleaned up the reducer. I suggest you create a createReducer.js helper and play around with it, it made my code more readable which is imo the most important thing.
Enjoy writing less boilerplate code for your Redux reducers.