|
|
|
|
|
by andrewstuart
2719 days ago
|
|
I'm all for an advancement that simplifies things, and from the sound of it, hooks enables writing of simpler code. Two things stand out about hooks to me (from what I have read, have not used them yet): 1: well suited to writing functions rather than classes - this is appealing because there is a line of thinking that values function composition over object orientation. 2: it sounds this finally solves one of the major challenges in react which is simple cross cutting. Cross cutting was always painful and I'll be very happy if this is cleanly solved. I'm hesitant about new functionality that increases complexity, or is harder to understand and grasp. I'm very enthused about anything that goes the other way.... the industry must constantly strive for simpler ways to do everything. |
|
For me simplicity is the three C:
Clarity, in terms of how many concepts do I need to know to understand given some lines of code. The fewer the better.
Coherence, how similar is the expressions I write to what I want to say in terms of the given language. The more similar the better.
Confound, how surprising is the behavior of the code? the less the better.
The issue with hooks I think is that they're trying to treat symptoms rather than solve the problem, if you read the original motivation document by Dan, it talks about State Logic Reuse, Complex Components and People Don't Understand Classes; I think these problems can be tackled much better by their own without trying to add more APIs to React or taking drastic measures like completely change the way people think about React components.