DEV Community

Discussion on: React with Typescript

 
konstagap profile image
konstagap

Why do u think nested object is something that no one should ever do? I deal with forms and I have lots of nested objects that has arrays of objects and so on, I use one single object to keep all together in form, to update one field I just shallow copy old object, change field, pass new reference to setState and it works no problem, Is there another way how to do it?

Thread Thread
 
joaolss profile image
João Lucas Silva

useReducer would be much better to deal with nested objects inside a state