Hacker News new | ask | show | jobs
by joshxyz 1925 days ago
When you instantiate a function(){}, you can get private class properties. Cant get that on es6 classes without babeljs. Cant instantiate es6 arrow functions too.

On reactjs, the flow is much more smoother with hooks instead of class instances because there is no more need to bind functions to your class instances in your class constructor;

there is no need to refer to `this` (on hooks you work with vars directly), and on hooks you are forced to treat things immutably (when you are calling set_value(new_value) instead of mutating the class state directly;

and the useEffect hooks give you a better control and grip on the react component lifecycle.

I honestly avoid usage of es6 classes unless I have to extend another class (e.g. extending Error for custom errors, or extending nodejs EventEmitter).