DEV Community

Discussion on: React - You might not need that many states!

Collapse
 
noriller profile image
Bruno Noriller

Not sure about this one...
If you have multiple source of states and each one have a name or something like data-attribute with something unique, you don't even need to know the keys from the function.
The reducer, as you added there is just another point you have to maintain.

Of course... this would be assuming you only need to do the same thing for each one.

And you could still just make { ...state, [action.type]: action.payload } maybe after filtering whatever don't fit the mold.