News for hackers. Stuff that matters.
Re:Common mistakes writing React components with hooks by brlewis on Tuesday July 21, 2020 @11:26AM (#23907557)
Yes. The author should replace "This is dangerous" with "This is a tiny bit sub-optimal" in the first example.

EDIT: "This is dangerous" is also the wrong label for the 2nd example. Should be "This is not the cleanest way"

EDIT2: "This is dangerous" is also the wrong label for the 3rd example. Should be "This is not the most readable". I'd also note that I'm surprised the author has seen this mistake a lot; the "solution" looks like the happy path most people would follow in the first place.

EDIT3: "This is dangerous" in the 4th example should be replaced with "This could be simplified"

EDIT4: "This is dangerous" in the 5th example should be "This makes redundant API calls". I'd also note that I'm surprised this example is even included. How could anyone miss that fetchData() is being called every time updateBreadcrumbs() is called?

Re:Common mistakes writing React components with hooks by vvpan on Tuesday July 21, 2020 @11:54AM (#23907867)
Yeah, there are gotchas and issues with hooks and some of them are quiet common but this article does not cover those. Odd selection of "mistakes".
Re:Common mistakes writing React components with hooks by jgwil2 on Tuesday July 21, 2020 @05:34PM (#23911251)
Well, example 2 is legitimately dangerous if your app is required to be accessible.