I agree. Optimizing a developer library for developers who struggle to understand what a class is seems like a good way to build something very convoluted.
I don't think the issue is "what is a class". It's more that the lifecycle functions get tied into the class, and you end up with a ball of highly conditional logic. It's easy for newbies to just add stuff to make it work, but end up with a mess.
React is the view layer, so the class concept of "here's some data and methods to alter it" doesn't really match with what happens - I don't know that components every should have been classes in the first place.
According to the article yes, the issue is "what is a class":
"You have to understand how this works in JavaScript, which is very different from how it works in most languages. You have to remember to bind the event handlers." etc.
It's not just having to understand what a class is, it's also having to know and remember to add a constructor to your class just to call `this.handleSomeEvent = this.handleSomeEvent.bind(this)`.
Sure, I know what it does and why it is needed, but it is ugly, cumbersome, and I keep forgetting it nonetheless.
There are other ways to approach an issue beyond shoving everything into a class. I'm not sure I really like the new hooks over the state methods at that level since I tend to separate global state (redux) vs component state (class) vs component state rendering (functional component).
In the end it depends on your style. I think this might be useful in a way that can be more pure than some other methods might be.
ergothus|7 years ago
React is the view layer, so the class concept of "here's some data and methods to alter it" doesn't really match with what happens - I don't know that components every should have been classes in the first place.
xab9|7 years ago
"You have to understand how this works in JavaScript, which is very different from how it works in most languages. You have to remember to bind the event handlers." etc.
Vinnl|7 years ago
Sure, I know what it does and why it is needed, but it is ugly, cumbersome, and I keep forgetting it nonetheless.
beaconstudios|7 years ago
- https://www.npmjs.com/package/babel-plugin-autobind-class-me...
- https://www.npmjs.com/package/babel-plugin-transform-class-p...
tracker1|7 years ago
In the end it depends on your style. I think this might be useful in a way that can be more pure than some other methods might be.
AlexCoventry|7 years ago