2 ms·
Most of the time simple objects/collections work... separating data from utility is often cleaner and easier to reason about. That said, when you need encapsul
by tracker1 11y ago
Most of the time simple objects/collections work... separating data from utility is often cleaner and easier to reason about.
That said, when you need encapsulation and instance isolation classes provide a nice sugar around prototyping. They tend to work very well for components that have visual interactions/events that are tethered to instance/scope state. I tend to prefer the React+Redux model myself, but there are times when you need more than render-only components, and in those cases the class syntax means cleaner source code imho. These cases are also very limited imho, and about the only place I use class syntax.