Is there a way to structure const reducer = (state = initialState, action)
in such a manner that the method isn't bloated by a bunch of switch cases?
My idea was to put related actions in arrays and check them with Array.prototype.includes()
when handling an action.
I would then extract the switch cases that correlate to specific actions in new methods (for example the List
component would have LIST_ADD
, LIST_REMOVE
etc.) and call those methods instead of just running through 100 cases in the const reducer = (state = initialState, action)
method.
That would tax performance but it would be at least structured.
Any better ideas?