This is not very accurate. If you read this article, read through all of the comments. The author has confused most of what he is talking about.
, you should probably delete this article or make changes after reading through and understanding the comments. This will lead to confusion in the future for other developers.
Hi I didn't propose any wrong solution for the problem , I'm just telling don't do this mistake while using react-hooks . If this problem is wrong provide an working demo i'll remove the post
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.
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.