Supplying a brand new array will definitely call the hook. The issue is if you maintain the same array, what the hook is fired based on is changed identity. So if you create a new object / array then the hook will fire. If you don't and merely update it, it won't. It's not a react hooks issue. It's is entirely based on Javascript identity. See reference vs value types.
again i'm trying to address an issue based on the scenario where an value in the object gets updated hooks will be called again even the previous value in the object and the current updated value are same
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Supplying a brand new array will definitely call the hook. The issue is if you maintain the same array, what the hook is fired based on is changed identity. So if you create a new object / array then the hook will fire. If you don't and merely update it, it won't. It's not a react hooks issue. It's is entirely based on Javascript identity. See reference vs value types.
again i'm trying to address an issue based on the scenario where an value in the object gets updated hooks will be called again even the previous value in the object and the current updated value are same
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.