My religious conversion (Angular vs React)
— Typescript, Angular, React, effectiveness — 2 min read
For years I have been a member of the ReactJS fan club, around 2016 I even ported a very old but very large angularjs 1.x app to reactjs, because I was such a big fan of reactjs. Looking back that was probably hype-based-refactoring, but I was young and eager to be with the cool kids.
But recently I have been working a lot in Angular 16+, and I have come to realize that I've been blinded for the truth. The truth is that react hooks suck balls, the react-lifecycle methods weren't great but at least classes made sense.
Now in all honesty, it was this blog "Can we all just admit React hooks were a bad idea?", by Amy Blankenship, that solidified my belief that react hooks are a bad idea. I know everybody always had issues with the react-lifecycle methods, but at least they were understandable.
React hooks are magic, dark magic. I know I can look into it, but from the top of my head I cannot tell you how they function internally. But all the OOP arguments Amy made in her blog are great points, that I can agree with... now that I am a wiser and older developer/architect. To summarize her 3 part blog:
- separation of concerns, in react your logic and view are in the same component, in the same file. In angular you have a controller (js-component class) and a view (html+js-template).
- decoupling, in react you inevitably couple your components to the state management system, unless you use a library like Redux. In angular dependency injection makes it possible to inject different services for different environments, the angular services with RXJS are a good starting point for state management, but a Redux-like state management system like NgRx is also possible and because dependency injection makes switching things out significantly easier.
- extendability, react function-components and react-hooks cannot be extended, only composed. In angular things are js-classes, which can be extended.
But most importantly, the react-hooks are dark magic, and I don't like dark magic.