3 ms·
Evan You (Vue author) had a great quote about this: A mutable model that you can reliably understand is better than an immutable one that leaks. T
by CharlieDigital 3y ago
Evan You (Vue author) had a great quote about this:
A mutable model that you can reliably understand is better than an immutable one that leaks.
The pain and suffer of hooks all roots from the mismatch between a dogmatic belief in the superiority of immutability and the harsh reality of the host language that is JavaScript.
React's render cycle is fundamentally mis-aligned with JavaScript since the re-render requires that you correctly manage state and references in the path of the render cycle by moving it out of the way with a hook.
It all feels quite unnatural as someone who has been writing JavaScript since the last 90's.
https://twitter.com/youyuxi/status/1629636673519894528 https://twitter.com/youyuxi/status/1629636673519894528
https://twitter.com/youyuxi/status/1629636967473496064 https://twitter.com/youyuxi/status/1629636967473496064
- satvikpendem 3y agoIt makes sense when you realize that React concepts were originally conceived in OCaml by Jordan Walke, who also made ReasonML as a JS(X)-like syntax over OCaml. OCaml is almost all functional, with immutable variables, so this was brought over to React.
- zarzavat 3y agoI agree with the sentiment that JS is the wrong language for React, but it’s not such a big deal in practice. The key is to write your own hooks specialized for the project, then the complexity is isolated into one place where you are expecting it, instead of dispersed across your project. If you are trying to write everything using the built-in hooks then you’re going to have a bad time.
- CharlieDigital 3y ago> you’re going to have a bad time Have a good time and use any of the other options available. Vue, Solid, Preact, Svelte, Lit, Vanilla.