I think I have found some unnecessary code on one of the react lessons (please correct me if I’m wrong). On the screenshot below you can see my edited code left and on the right the code from the start of the lesson. I was trying to workout why we needed to deconstruct prevState.newTask and have it as part of the newTask we are creating. I decided to edit the code to how I thought it should be and it seemed to work exactly the same. Can someone either confirm that this code isn’t needed or tell me why it is?
Another question is why is there square brackets around the ‘name’ key?
It is on the final lesson (lesson 9) of ‘The state hook’ within the react course.