Angular vs React: What to Choose for Your App?
TA precise side-by-side comparison of general and technical aspects of Angular and React
There are so many articles titled “Angular vs React”, “React vs Angular”, “Angular or React” – it is a miracle you opened this one! The topic is so trite and unoriginal, only a lazy person has not written an article on this one.

What these articles are missing, however, is a precise side-by-side comparison of Angular vs React.
So this is what I am going to do in this blog post: to place React and Angular in direct juxtaposition, to review and contrast the two JavaScript frameworks on each possible characteristic, and to make sure that neither one misses even a single piece of data.
Finally, I am not going to tell you which technology to choose. But I will give you enough food for thought for you to choose the technology that suits you and your project best.



1. Brief Overview
React
React is a JavaScript library for UI development. It is managed by Facebook and an open-source community of React developers.
The framework was introduced in May 2013.
The latest updates were released on March 22nd, 2021 – over 5 months ago.
Angular
Angular is an open-sourced JavaScript framework for web and mobile development. It is TypeScript-based and managed by Google’s Angular Team and the AngularJS developers community.
Launched in September 2016, Angular (also known as Angular 2.0) is a complete rewrite of AngularJS (Angular 1.0), which was introduced in 2010.
There have been 12 versions of Angular already, and the latest release took place on May 12, 2021 – three months ago.
2. Universality
React
React is a framework used in both web and mobile development. However, for mobile development, it needs to be incorporated with Cordova. Moreover, for mobile development, there is an additional framework – React Native.
React can be used to build both single-page and multiple-page web applications.
Angular
Angular is suitable for both web and mobile development. In mobile development, however, a great share of work is done by Ionic. Furthermore, similarly to React, Angular has an additional mobile development framework. The counterpart of React Native is NativeScript.
Angular can also be used for both single- and multiple-page web apps.
3. Self-Sufficiency
React
React is a framework for UI development, so apps written with React need additional libraries to be used. For instance, Redux, React Router, or Helmet optimize the processes of state management, routing, and interaction with the API. Such functions as data binding, component-based routing, project generation, form validation, or dependency injection require additional modules or libraries to be installed.
Angular
Angular is a full-fledged framework for software development, which usually does not require additional libraries. All the above-mentioned functions – data binding, component-based routing, project generation, form validation, and dependency injection – can be implemented with the means of Angular package.
4. Learning Curve
React
React is minimalistic: no dependency injection, no classic templates, no overly complicated features. The framework will be quite simple to understand if you already know JavaScript well. However, it takes quite some time to learn how to set up a project because there is no predefined project structure. The Redux library, which is used in more than half of React applications for state management, also needs to be learned. Constant framework updates also require additional effort from the developer. Furthermore, there are quite a lot of best practices in React, which you will need to learn to do things right.
Angular
Angular itself is a huge library, and learning all the concepts associated with it will take much more time than in the case of React. Angular is more complex to understand, there is a lot of unnecessary syntax, and component management is intricate. Some complicated features are embedded into the framework core, which means that the developer cannot avoid learning and using them. Moreover, there are a lot of ways of solving a single issue. Although TypeScript – the basic Angular programming language – closely resembles JavaScript, it also takes some time to learn. Since the framework is constantly updated, the developer needs to put some extra learning effort.
5. Community
React
React framework is one of the most popular JS frameworks worldwide, and the community supporting and developing it is huge.
Working with React, you have to be a continuous learner since the framework is often updated. While the community tries to go forward with the latest documentation as swiftly as possible, keeping up with all the changes is not that easy. Sometimes, there may be a lack of documentation, but the issue is often solved by the community support on thematic forums.
React is actively used by such companies as Facebook, Twitter, Netflix, Airbnb, PayPal, The New York Times, Yahoo, Walmart, Uber, and Microsoft.
Angular
Angular is less admired than React and faces a lot of skepticism, partially because of the unpopularity of Angular 1.0. Developers used to dismiss the framework as an overly complicated one as it required a lot of time to be spent learning. However, this framework has been developed by Google, which works in favor of Angular’s credibility.
Google provides the long-term support of the framework and constantly improves it. However, the updates are so fast that the documentation often falls behind.
Angular is used by such companies as McDonald’s, AT&T, HBO, Apple, Forbes, Adobe, Nike, and Microsoft as well.
6. Performance
React
React’s performance is greatly improved with the introduction of virtual DOM. Since all virtual DOM trees are lightweight and built on server, the load on browser is reduced. Furthermore, since the data-binding process is unidirectional, bindings are not assigned watchers as in the case of Angular. Respectively, no additional workload is created.
Angular
Angular performs worse, especially in the case of complex and dynamic web apps.
The performance of Angular app is negatively affected by bidirectional data-binding. Each binding is assigned a watcher to track changes, and each loop continues until all the watchers and associated values are checked. Respectively, the more bindings you have, the more watchers are created, and the more cumbersome the process becomes.
However, the most recent update of Angular has greatly improved its performance, and it does not lose to React anymore. Moreover, the size of an Angular application is slightly smaller than the size of a React app.
7. Language
React
React is based on JavaScript ES6+ combined with JSX script. JSX is an extension for syntax, which makes a JavaScript code resemble that written in HTML. Respectively, the code is easier to understand, and typos are easier to spot. For the JSX code to be compiled in a browser, React is augmented with Babel – a code translation tool.
Angular
Angular can use JavaScript or TypeScript, which is a superset of JS developed specifically for larger projects. TypeScript is more compact than JavaScript, the code is easier to navigate, and typos are easily spotted. Code refactoring process also becomes simpler and faster.

8. App Structure
React
The structure of React provides developers with the freedom to choose. There is no “the only right structure” for a React app. However, the necessity to design the app structure at the beginning of each project makes it more difficult and longer to start.
Besides, React offers only View layer, while Model and Controller are added with the usage of other libraries.
The architecture of a React app is component-based. The code is made of React components, which are rendered with React DOM library and directed in two ways: functional (with a function that returns JSX)…
1 2 3 4 5 6 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"><span class="token" style="color: rgb(0, 119, 170);">function</span> <span class="token" style="color: rgb(221, 74, 104);"><span class="token maybe-class-name">Hello</span></span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token parameter">props</span><span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(0, 119, 170);">return</span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span>div<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span><span class="token maybe-class-name">Hello</span> <span class="token" style="color: rgb(153, 153, 153);">{</span>props<span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">name</span><span class="token" style="color: rgb(153, 153, 153);">}</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">/</span>div<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span> <span class="token" style="color: rgb(153, 153, 153);">}</span> |
…and class-based (with ES6 classes).
1 2 3 4 5 6 7 8 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span><span class="react-syntax-highlighter-line-number">4 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"><span class="token" style="color: rgb(0, 119, 170);">class</span> <span class="token" style="color: rgb(221, 74, 104);">Hello</span> <span class="token" style="color: rgb(0, 119, 170);">extends</span> <span class="token" style="color: rgb(221, 74, 104);">React<span class="token" style="color: rgb(153, 153, 153);">.</span>Component</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(221, 74, 104);">render</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(0, 119, 170);">return</span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span>h1<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span><span class="token maybe-class-name">Hello</span><span class="token" style="color: rgb(153, 153, 153);">,</span> <span class="token" style="color: rgb(153, 153, 153);">{</span><span class="token" style="color: rgb(0, 119, 170);">this</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">props</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">name</span><span class="token" style="color: rgb(153, 153, 153);">}</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">/</span>h1<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> |
React components are cohesive and reusable, which makes the app perfectly scalable.
Angular
The structure of Angular is fixed and complex, suitable for experienced developers.
Angular is based on three layers – Model, Controller, and View. An object responsible for the Model is initialized by the Controller and displayed with the View.
The application code consists of different Angular components, each being written in four separate files: a TypeScript to implement the component, an HTML file to define the view, a CSS file to define the stylistic features, and a special file for testing purposes. Links to these files are written in the app directive, which displays the structural logic of the app. Respectively, Angular components are also reusable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span><span class="react-syntax-highlighter-line-number">4 </span><span class="react-syntax-highlighter-line-number">5 </span><span class="react-syntax-highlighter-line-number">6 </span><span class="react-syntax-highlighter-line-number">7 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"><span class="token module" style="color: rgb(0, 119, 170);">import</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token maybe-class-name">Component</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token module" style="color: rgb(0, 119, 170);">from</span> <span class="token" style="color: rgb(102, 153, 0);">'@angular/core'</span><span class="token" style="color: rgb(153, 153, 153);">;</span> @<span class="token" style="color: rgb(221, 74, 104);"><span class="token maybe-class-name">Component</span></span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">{</span> selector<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token" style="color: rgb(102, 153, 0);">'my-app'</span><span class="token" style="color: rgb(153, 153, 153);">,</span> templateUrl<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token" style="color: rgb(102, 153, 0);">'./app.component.html'</span><span class="token" style="color: rgb(153, 153, 153);">,</span> styleUrls<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token" style="color: rgb(153, 153, 153);">[</span><span class="token" style="color: rgb(102, 153, 0);">'./app.component.css'</span><span class="token" style="color: rgb(153, 153, 153);">]</span> <span class="token" style="color: rgb(153, 153, 153);">}</span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token module" style="color: rgb(0, 119, 170);">export</span> <span class="token" style="color: rgb(0, 119, 170);">class</span> <span class="token" style="color: rgb(221, 74, 104);">AppComponent</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> |
9. UI Components
React
UI tools for React are developed by the community. There are a lot of free and paid UI components on the React portal. To use material design components in React, you would have to install an additional library – Material-UI Library & Dependencies.
Angular
Angular has a built-in Material toolset, and it offers a variety of pre-built material design components. There are various buttons, layouts, indicators, pop-ups, and form controls. Respectively, UI configuration becomes simpler and faster.
10. Directives
React
In React, templates and logic are explained in one place – at the end of the component. It allows the reader to quickly grasp the meaning of the code even if they do not know the syntax.
Angular
In Angular, each template is returned with an attribute – a directive of how the object has to be set. The syntax of Angular directives is complex and sophisticated, which makes it incomprehensible for a reader without any experience in working with this technology.
11. State Management
React
In React, each component has its own state. A React developer can create special components for holding the state of the entire application or a particular part of it. The major disadvantage here consists in the fact that the global state needs to be stored in multiple different parts of the app with data being manually passed around different component tree levels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span><span class="react-syntax-highlighter-line-number">4 </span><span class="react-syntax-highlighter-line-number">5 </span><span class="react-syntax-highlighter-line-number">6 </span><span class="react-syntax-highlighter-line-number">7 </span><span class="react-syntax-highlighter-line-number">8 </span><span class="react-syntax-highlighter-line-number">9 </span><span class="react-syntax-highlighter-line-number">10 </span><span class="react-syntax-highlighter-line-number">11 </span><span class="react-syntax-highlighter-line-number">12 </span><span class="react-syntax-highlighter-line-number">13 </span><span class="react-syntax-highlighter-line-number">14 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"><span class="token" style="color: rgb(0, 119, 170);">class</span> <span class="token" style="color: rgb(221, 74, 104);">Clock</span> <span class="token" style="color: rgb(0, 119, 170);">extends</span> <span class="token" style="color: rgb(221, 74, 104);">React<span class="token" style="color: rgb(153, 153, 153);">.</span>Component</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(221, 74, 104);">constructor</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token parameter">props</span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(0, 119, 170);">super</span><span class="token" style="color: rgb(153, 153, 153);">(</span>props<span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(0, 119, 170);">this</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">state</span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span> <span class="token" style="color: rgb(153, 153, 153);">{</span>date<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token" style="color: rgb(0, 119, 170);">new</span> <span class="token" style="color: rgb(221, 74, 104);">Date</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(153, 153, 153);">}</span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token" style="color: rgb(221, 74, 104);">render</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(0, 119, 170);">return</span> <span class="token" style="color: rgb(153, 153, 153);">(</span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span>div<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span>h1<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span><span class="token maybe-class-name">Hello</span> world<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">!</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">/</span>h1<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span>h2<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span><span class="token maybe-class-name">Now</span> is <span class="token" style="color: rgb(153, 153, 153);">{</span><span class="token" style="color: rgb(0, 119, 170);">this</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">state</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">date</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token method property-access" style="color: rgb(221, 74, 104);">toLocaleTimeString</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(153, 153, 153);">}</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">/</span>h2<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);"><</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">/</span>div<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">></span> <span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> |
To solve this problem, there is a special state management library – Redux. The idea of it is that the global state is represented as a single stateful object, which is altered in different parts of the app with the help of reducers – special Redux functions.
Another solution is offered by the state management library MobX. Unlike Redux with the global state stored in a single immutable stateful object, MobX offers storing only the minimal required state, while the rest of it can be derived.
Angular
In Angular, component data is stored in component properties. Parent components pass data through to children ones. State changes in some parts can be identified and recalculated, but in a large app, it can cause a multi-directional tree series of updates, which will be difficult to track. The features can be improved with the help of state management libraries, such as NgRx or RxJS, which would make sure that the data flow is unidirectional.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span><span class="react-syntax-highlighter-line-number">4 </span><span class="react-syntax-highlighter-line-number">5 </span><span class="react-syntax-highlighter-line-number">6 </span><span class="react-syntax-highlighter-line-number">7 </span><span class="react-syntax-highlighter-line-number">8 </span><span class="react-syntax-highlighter-line-number">9 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"><span class="token module" style="color: rgb(0, 119, 170);">export</span> <span class="token" style="color: rgb(0, 119, 170);">class</span> <span class="token" style="color: rgb(221, 74, 104);">HeroListComponent</span> <span class="token" style="color: rgb(0, 119, 170);">implements</span> <span class="token" style="color: rgb(221, 74, 104);">OnInit</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> heroes<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token maybe-class-name">Hero</span><span class="token" style="color: rgb(153, 153, 153);">[</span><span class="token" style="color: rgb(153, 153, 153);">]</span><span class="token" style="color: rgb(153, 153, 153);">;</span> selectedHero<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token maybe-class-name">Hero</span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(221, 74, 104);">constructor</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token parameter"><span class="token" style="color: rgb(0, 119, 170);">private</span> service<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token maybe-class-name">HeroService</span></span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token" style="color: rgb(221, 74, 104);">ngOnInit</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(0, 119, 170);">this</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">heroes</span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span> <span class="token" style="color: rgb(0, 119, 170);">this</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">service</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token method property-access" style="color: rgb(221, 74, 104);">getHeroes</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token" style="color: rgb(221, 74, 104);">selectHero</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token parameter">hero<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token maybe-class-name">Hero</span></span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(0, 119, 170);">this</span><span class="token" style="color: rgb(153, 153, 153);">.</span><span class="token property-access">selectedHero</span> <span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span> hero<span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> |
12. Dependency Injection
React
React does not fully support dependency injection as it does not fully comply with the idea of functional programming and data immutability. Instead, it has a global state for all components.
Angular
The greatest advantage of Angular rests in the fact that, unlike React, it supports dependency injection. Therefore, Angular allows having different lifecycles for different stores.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span><span class="react-syntax-highlighter-line-number">4 </span><span class="react-syntax-highlighter-line-number">5 </span><span class="react-syntax-highlighter-line-number">6 </span><span class="react-syntax-highlighter-line-number">7 </span><span class="react-syntax-highlighter-line-number">8 </span><span class="react-syntax-highlighter-line-number">9 </span><span class="react-syntax-highlighter-line-number">10 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"><span class="token module" style="color: rgb(0, 119, 170);">import</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token maybe-class-name">Injectable</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token module" style="color: rgb(0, 119, 170);">from</span> <span class="token" style="color: rgb(102, 153, 0);">'@angular/core'</span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token module" style="color: rgb(0, 119, 170);">import</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(153, 0, 85);">HEROES</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token module" style="color: rgb(0, 119, 170);">from</span> <span class="token" style="color: rgb(102, 153, 0);">'./mock-heroes'</span><span class="token" style="color: rgb(153, 153, 153);">;</span> @<span class="token" style="color: rgb(221, 74, 104);"><span class="token maybe-class-name">Injectable</span></span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: slategray;">// we declare that this service should be created</span> <span class="token" style="color: slategray;">// by the root application injector.</span> providedIn<span class="token" style="color: rgb(153, 153, 153);">:</span> <span class="token" style="color: rgb(102, 153, 0);">'root'</span><span class="token" style="color: rgb(153, 153, 153);">,</span> <span class="token" style="color: rgb(153, 153, 153);">}</span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token module" style="color: rgb(0, 119, 170);">export</span> <span class="token" style="color: rgb(0, 119, 170);">class</span> <span class="token" style="color: rgb(221, 74, 104);">HeroService</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(221, 74, 104);">getHeroes</span><span class="token" style="color: rgb(153, 153, 153);">(</span><span class="token" style="color: rgb(153, 153, 153);">)</span> <span class="token" style="color: rgb(153, 153, 153);">{</span> <span class="token" style="color: rgb(0, 119, 170);">return</span> <span class="token" style="color: rgb(153, 0, 85);">HEROES</span><span class="token" style="color: rgb(153, 153, 153);">;</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token" style="color: rgb(153, 153, 153);">}</span> |
13. Data Binding
React
Data binding stands for the data synchronization process between Model and View.
React should be augmented with Redux, which allows working with immutable data and making data flow unidirectional. Unidirectional binding is predictable, which facilitates the debugging process.
Angular
Angular works with bidirectional data-binding and mutable data. While the advantages of mutable and immutable data are a matter of a heated discussion, it is definitely easier to work with bidirectional data-binding rather than with the unidirectional approach. At the same time, bidirectional data-binding negatively affects the performance since Angular automatically develops a watcher for each binding.
The ways of data-binding in Angular:
1 2 3 4 5 6 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"><span class="token" style="color: rgb(153, 153, 153);">{</span><span class="token" style="color: rgb(153, 153, 153);">{</span>expression<span class="token" style="color: rgb(153, 153, 153);">}</span><span class="token" style="color: rgb(153, 153, 153);">}</span> <span class="token maybe-class-name">Interpolation</span> <span class="token" style="color: rgb(153, 153, 153);">[</span>target<span class="token" style="color: rgb(153, 153, 153);">]</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span><span class="token" style="color: rgb(102, 153, 0);">"expression"</span> <span class="token maybe-class-name">Property</span> bind<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">-</span>target<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span><span class="token" style="color: rgb(102, 153, 0);">"expression"</span> <span class="token maybe-class-name">Attribute</span> |
1 2 3 4 5 6 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"> <span class="token" style="color: rgb(153, 153, 153);">(</span>target<span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span><span class="token" style="color: rgb(102, 153, 0);">"statement"</span> <span class="token maybe-class-name">Event</span> on<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">-</span>target<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span><span class="token" style="color: rgb(102, 153, 0);">"statement"</span> <span class="token maybe-class-name">Event</span> |
1 2 3 4 5 6 |
<span class="react-syntax-highlighter-line-number">1 </span><span class="react-syntax-highlighter-line-number">2 </span><span class="react-syntax-highlighter-line-number">3 </span></code><code style="color: black; background: none; text-shadow: white 0px 1px; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; overflow-wrap: normal; line-height: 1.5; tab-size: 4; hyphens: none;"> <span class="token" style="color: rgb(153, 153, 153);">[</span><span class="token" style="color: rgb(153, 153, 153);">(</span>target<span class="token" style="color: rgb(153, 153, 153);">)</span><span class="token" style="color: rgb(153, 153, 153);">]</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span><span class="token" style="color: rgb(102, 153, 0);">"expression"</span> <span class="token maybe-class-name">Two</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">-</span>way bindon<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">-</span>target<span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">=</span><span class="token" style="color: rgb(102, 153, 0);">"expression"</span> <span class="token maybe-class-name">Two</span><span class="token" style="color: rgb(154, 110, 58); background: rgba(255, 255, 255, 0.5);">-</span>way |
14. Change Rendering
React
React uses a virtual Document Object Model (DOM), which enables easily implementing minor data changes in one element without updating the structure of the entire tree. The framework creates an in-memory cache of data structure, computes the changes, and efficiently updates the DOM displayed in the browser. This way, the entire page seems to be rendered on each change, whereas actually, the libraries render changed subcomponents only. The React team is constantly improving Fiber – a mechanism aimed at boosting the productivity of change rendering.
Angular
Angular uses real DOM, which updates the entire tree structure even when the changes have taken place in a single element. Real DOM is considered to be slower and less effective than virtual DOM. To compensate for this disadvantage, Angular uses change detection to identify components that need to be altered. Respectively, real DOM on Angular performs as effectively as virtual DOM on React.
15. Tools
React
React is supported by multiple code editors. For instance, the code in React can be edited with Sublime Text, Visual Studio, and Atom. To bootstrap a project, you can use the Create React App (CLI) tool. In turn, server-side rendering is completed with the use of Next.js framework.
To test the entire app written in React, you would need multiple tools. For instance, Enzyme for component testing, Jest for testing JS code, React-unit for unit testing and so on. To debug the app in the development mode, you can use a browser extension React Dev Tools.
Another interesting tool is React 360, which is a library used for creating AR and VR applications.
Angular
Similarly to React, Angular is supported by a variety of code editing tools. For example, you may work with such code editors as Aptana, Sublime Text, and Visual Studio. A project can be promptly set up with Angular CLI. Server-side rendering is completed with the help of Angular Universal.
Unlike React, Angular can be fully tested with a single tool. For the end-to-end testing in Angular, the platforms are Jasmine, Protractor, and Karma. Another tool that debugs the app in the development mode is a browser extension Augury.
To Wrap Up
Angular is a full-fledged mobile and web development framework. React is a framework only for UI development, which can be turned into a full-fledged solution with the help of additional libraries.
There is a vivid difference between React and Angular. React seems simpler at first sight, and it takes less time to start working on a React project. However, simplicity as the outspoken advantage of React is neutralized with the necessity to learn to work with additional JavaScript frameworks and tools. Angular itself is more complex and takes quite some time to master. Yet, it is a powerful tool that offers a holistic web development experience, and once you learn how to work with it, you reap the fruits.
There is no better framework. Both are updated continuously to keep up with the competitor. For instance, while React was believed to win because of its virtual DOM, Angular equaled the score by implementing change detection. While Angular was considered to be winning because of being developed by such an authoritative company as Google, the immense devoted React community fully compensated for Google‘s reputation and made React similar to Angular.
Eventually, React vs Angular is all a matter of personal preference, a matter of skills and habits. As a beginner in programming, you would probably benefit more from starting with React. As an experienced developer, you just keep working with what you know better. Do not forget to challenge yourself and start learning a new framework, React or Angular. As a Project Manager or a business owner outsourcing developers, you should talk to your web development team and together choose the framework that suits all of you best, would it be Angular or React.
I would like to say thank you to everyone who contributed to this article including Sergey Gornostaev and Volodya Andrushchak, full-stack software developers @ KeenEthics.
Do you have an idea for a project?
If there is something you need assistance with, we will be happy to share our experience or to help you implement the idea! As a both AngularJS development and ReactJS development company, we will help you choose the most suitable framework and develop a high-quality product.