DEV Community

Discussion on: Common mistake done while using react hooks

 
karthick30 profile image
KaRthick

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

Thread Thread
 
tonestrike profile image
Tony Giorgi • Edited

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.