News for hackers. Stuff that matters.
Re:React Won by Default – and It's Killing Front End Innovation by the_gipsy on Tuesday September 16, 2025 @10:36AM (#45262852)
The complaint is that it's not just "function composition" (per GP) at all anymore. You're dealing with "component lifecycles". Composition doesn't really work out with hooks, for reference see any non-toy React codebase.
Re:React Won by Default – and It's Killing Front End Innovation by patates on Tuesday September 16, 2025 @11:05AM (#45263313)
It's like dealing with event handler registrations. You cannot compose those too, as they are "hooks" for when a specific event occurs.

Hook definitions can be a composition of reusable functions and other hooks, like any event handlers (e => filterKeys('cmd+s, ctrl+s', preventDefault(e)).then(save)). It's possible to break this anology (you can register an event handler in an if branch) but I hope it gets the point across.

Re:React Won by Default – and It's Killing Front End Innovation by wredcoll on Tuesday September 16, 2025 @02:19PM (#45265842)
> It's like dealing with event handler registrations. You cannot compose those too, as they are "hooks" for when a specific event occurs.

Yes, and those are frequently annoying also. Literally the point of the article is the friction they introduce and questioning whether there are better ways to do things. Sometimes there are.

Re:React Won by Default – and It's Killing Front End Innovation by spicebox on Wednesday September 17, 2025 @02:33PM (#45279619)
The whole reason that hooks were created was that they could composed, as opposed to stuff like renderprops or mixins. When you create a custom hook that uses a useState and a useEffect, that's composition. They have the caveat that they can only be composed into new hooks, but that's just like async functions only being able to be called from other async functions.