I only wish you'd do the obvious, idiomatic thing - instead of hiding the current component in a global variable, make it plain what's actually going on:
I like that concept also, it can solve some issues, but may introduce others.
Using named exports alow for better tree-shaking and better minification, making all composition functions optional.
The way you specify it needs to create a object with all the functions binded.
Thanks for bringing this to discussion. We can find the pros and cons of both approachs and decide where to go!
I like it! Better than hooks. 👍
I only wish you'd do the obvious, idiomatic thing - instead of hiding the current component in a global variable, make it plain what's actually going on:
Yes, slightly more repetitive - but takes all the initial mystery out of it, and avoids teaching newbs how to be "clever".
I don't know why anybody thinks it's more "elegant" to hide things in global state.
In my world, obvious beats clever, every time. Code should do what it looks like it does. That's my only real gripe with hooks. 🤷♂️
I like that concept also, it can solve some issues, but may introduce others.
Using named exports alow for better tree-shaking and better minification, making all composition functions optional.
The way you specify it needs to create a object with all the functions binded.
Thanks for bringing this to discussion. We can find the pros and cons of both approachs and decide where to go!
True.
But it doesn't have to be OOP - that was just an example.
We can do the same thing with functions:
My only point is don't hide your dependencies in global state.
I see your ideas.
Would be nice to discuss this better. Could you post your concern on the PR github.com/preactjs/preact/pull/1923
or on Preact Slack
preact.slack.com/
Done 🙂