|
|
|
|
|
by SebastianKra
1131 days ago
|
|
Rather I feel like there's a now fairly well known set of requirements, and every so often, a new framework comes around and says: "It's simple, we just don't consider this." For instance, the controllers introduced in Lit 2.0 feel like an admission that you forgot to consider the reasons why React moved away from classes in the first place. The example [1] could be written in less than half the amount of lines with hooks, and isn't any easier to understand.
Also, I can't find a solution for skipping expensive computations when re-rendering the component. Admittedly, I only skimmed Lit's documentation. But with the frameworks that I have tried, I came across cases where I had to either implement my own workaround, or the framework began introducing more and more concepts to fix their fundamentally broken approach (cough Aurelia). [1]: https://lit.dev/docs/composition/controllers/ |
|
A hook system takes some doing to build, controllers work like:
References from host to controller and controller to host are simple JS references that you can directly see in the debugger.The React custom hook is a bit shorter, but it's only 13 lines vs 17, and I think hooks are harder to understand because of how much is happening under the hood and the fact that for some reason you need two separate useEffect() calls.