News for hackers. Stuff that matters.
Re:Understanding UseMemo and UseCallback by captainmuon on Wednesday August 31, 2022 @02:51AM (#32659190)
It depends, they compose better until they don't. It is easy to mess hooks up if you do not call them in the right order, especially if they are nested (composed) in other functions. You need discipline to use them correctly.

Ironically they could have prevented this by making them more functional. Instead of some magic hidden state, you should have to always pass a context to them, and you should have to give every hook a unique name or a Symbol().

Re:Understanding UseMemo and UseCallback by HeyImAlex on Wednesday August 31, 2022 @10:18AM (#32662349)
I know they considered “keyed” hooks, but that api is a lot more verbose since you need to key _every_ hook you use, and hooks internally need to create a sub-hook context / namespace to avoid collisions which either needs to be managed manually _or_ means you can’t use plain functions as hooks (there would be some createHook function you’d run instead).