My code works, but I have a best practice question: I have an array of objects in the state, and a user interaction will change a value of one object at a time. As far a
If I understood your question right, you have an array of objects and when a property of a single object in array changes,
- Create a deep clone of the array and pass to setState
- Create a shallow clone and pass to setState
I just checked with the redux sample todo app and in case of a single property of an object changes you've to create a fresh copy of that single object not the entire array. I recommend you to read about redux and if possible use to manage the state of your app.