News for hackers. Stuff that matters.
Re:Frustrations with React Hooks by RussianCow on Tuesday September 10, 2019 @01:41PM (#20930932)
The issue I have with the "rules of hooks" is that it makes some previously trivial things cumbersome at best, and downright complicated at worst. For a quick example, something as simple as mapping an array onto a series of elements with a callback requires (as far as I can tell) that the inner element be broken out into its own component that calls `useCallback`, since you can't create a unique callback for each item in the parent.
Re:Frustrations with React Hooks by aidos on Tuesday September 10, 2019 @03:08PM (#20932170)
You don't need to use hooks there. You can just define your functions and be done with it.
Re:Frustrations with React Hooks by RussianCow on Tuesday September 10, 2019 @03:13PM (#20932247)
You do if you don't want those child components to be re-rendered needlessly when some higher-level state changes.