3 ms·
I'm no classical web developer, so I'm not be the best reference, but I used both a little bit for some realtime (mainly websocket driven) webapp for state visu
by Matthias247 11y ago
I'm no classical web developer, so I'm not be the best reference, but I used both a little bit for some realtime (mainly websocket driven) webapp for state visualization of remote embedded devices. I started with React, and I'm now on ng2 and happy with it (apart from some hopefully soon fixed bugs).
Imho both are ok. What I did not like that much with React was that the virtual DOM did not play nice all the time (strange effects can happen if you place non VDOM aware widgets inside it) and if you not take special care (keys) then reconcilation can produce a messed up representation. These things seem less problematic in ng2.
An unexpected very pleasant surprise for me was using the dependency injection mechanism in ng2 - I did not expect it do be useful because I never used something like this before. But now if any sub-sub-subcomponent in my view needs access to a status I don't need to pass it all the way down through unrelated components via props (like in React) but can directly inject it only in the using component. I also had good experiences with MVVM architecture from other projects with other frameworks, so I am happily using this approach also in ng2. For the model component I'm using service objects which are encapsulating the current state, exposing it through observables and are injected into the component (viewmodel) through DI. What I like here is that I can bind the view directly to the observables from the model with the help of async pipes and thereby get an auto-updating behavior with zero boilerplate code.
Apart from that there are obviously the major differences - angular has an inbuilt router, React not. But still I wouldn't think of Angular2 as something highly opinionated, you still have lots of flexibility.
As I am a big fan of typescript a factor for me was also that ng2 is typescript-first and I don't have to rely on possibly incomplete or 3rd party type definitions. But that might be more of a political factor, the basic typescript support for react is also good (it can even check the types of props in JSX - which currently not possible for ng2 templates) but many 3rd party libraries don't seem to provide type definitions.