You are creating a new array. This code is simply wrong and misleading. If you want to update the value of name for record 2, find the object in the array, update and set state to the same array. Then your code will make sense.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.