▲ | the_gipsy 3 hours ago | |
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. | ||
▲ | patates 3 hours ago | parent [-] | |
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. |