Hacker News new | ask | show | jobs
by moritzwarhier 977 days ago
Thing is, hook state looks like closures, but it's not the same at all.

The machinery behind the scenes might be ugly, but this syntax is also what I love about React Hooks.

I was preferring closures to ES6 classes before using React, despite the performance implications.

Since switching to TypeScript I also like ES classes though.

Especially for things like MobX... but even without it.

Regardless of React, I feel like classes are the context where getters and setters feel most natural and ergonomic.

And classes are great for grouping state and behavior in an easy-to-understand way.