4 ms·
I think the argument that hooks lose on simplicity (as opposed to familiarity) can hold water if you think about it this way: sure procedural code is very famil
by lhorie 7y ago
I think the argument that hooks lose on simplicity (as opposed to familiarity) can hold water if you think about it this way: sure procedural code is very familiar to most JS devs and consuming hooks indeed feels procedural. Ok. BUT. Reasoning about the rules of hooks when you're writing non-trivial hooks, that's not familiar, and it's not simple either. At my day job, there have been some debates about supporting Suspense composition and the semantics are very difficult to reason about because not only you have to keep in your head what the procedural code actually does, but you also need to keep track of whether e.g. certain flavors of certain expressions violate the rule of hooks. The term "magic" is a very appropriate way of describing how hooks feel in this context.
- chrisweekly 7y agoThanks for sharing. As someone who's done React for years (and webdev since 1998) but yet to do more w/ Suspense than read about it, it seems to me like [Suspense + Hooks] is an area where we're still some distance from solid idioms and established best practices. Maybe the APIs will undergo further refinement before that happens. As for magic (which, if good, decomposes into sane primitives), you might be right. But in general I appreciate the degree to which React's evolution over time has trended towards reducing the cognitive overhead of lifecycle concerns and state mgmt solutions. (To say nothing of reconciliation, which I'm perfectly happy to enjoy, whether it's voodoo or not.) /ramble