DEV Community

Discussion on: How To Efficiently Update React State For Multiple DOM Inputs Using the useReducer() Hook

Collapse
 
ivanbozhkov profile image
Ivan Bozhkov

Which is the heavy operation we are trying to avoid and how does one solution handle it better than the other? 😵‍💫

Collapse
 
kylewcode profile image
Kyle Williams

I wanted to avoid having more actions than was necessary. The first solution was an action for each input and the other a single action to handle them all. The second solution is better because it make the code easier to read and follow. If there's a problem with the logic, I'd just have to look under a single action to debug.

Collapse
 
kylewcode profile image
Kyle Williams

By heavy do you mean time/space complexity? If so, I couldn't really say, but what I did was geared more towards readability.