DEV Community

Discussion on: React hooks - working with state (objects)

 
joelynn profile image
Joseph Lynn • Edited

I agree that useReducer would be beneficial for complex state. However we are adding a static object in this case. We are not mangling the object state, we are copying the current state and adding a new object (which is exactly what useReducer would do but based on an action). It would not work to have separate state for id and name in this case - as they work together and identify the object.