4 ms·
A big problem with `this` is it is mutable. Dan Abramov has a nice article[1] explaining why that is a problem and how it leads to subtle bugs that are common i
by city41 7y ago
A big problem with `this` is it is mutable. Dan Abramov has a nice article[1] explaining why that is a problem and how it leads to subtle bugs that are common in React apps. Hooks eliminate this problem, and I would guess this was one reason they decided to move forward with them.
[1] https://overreacted.io/how-are-function-components-different-from-classes/ https://overreacted.io/how-are-function-components-different...
- jiofih 7y agoThat’s not a problem with “this”, but a self-inflicted problem from React’s chosen model of reusing class instances. It’s a design choice made by them and not a language issue at all.
- city41 7y agoTrue, although I did mean my comment in the context of React. Hooks are basically them rolling back this choice.