React is a JavaScript library for building user interfaces that uses a component-based approach. Components allow the user interface to be split into independent, reusable pieces. Data flows in one direction through the application via actions and a centralized state, rather than having two-way data binding. This unidirectional data flow model helps avoid bugs and makes the app more predictable and efficient. React uses a virtual DOM for rendering components, allowing it to efficiently update the real DOM when data changes.
8. App state vs. UI-state
DATA a.k.a. app state
UI-state
9. On new data
> Complete re-evaluation
> Comparison of result to displayed components
> Calculation of minimal set of changes
> Execution of changes
JS (fast)
DOM (slow)
22. React leverages
reactive programming
> Modelling of data-flow
> Data-changes are propagated automatically
+ No need to synchronize model <-> view (data-binding)
24. On code level (RxJS)
const subscription = todos
.filter(todo => !todo.completed)
.count()
.subscribe(
count => console.log(`There are ${count} uncompleted todos`),
err => console.log(`Something went wrong: ${err.message}`);
);
functional
programming
25. On architecture level (Angular 1)
http://tutorials.jenkov.com/images/angularjs/angularjs-critique-3.png
Data Service
Scope
ViewValidator
Controller
26. Problem: Loops in the flow
Error: [$rootScope:infdig] 10 $digest() iterations reached.
Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.4.3/$rootScope/infdig?p0=10&p1=%
at angular.js:68
...
450 Questions on Stackoverflow
39. Upshot
> Hierarchical components defined by interfaces
> Data is passed selectively top to bottom
> Complete re-evaluation on each action
> Unidirectional data flow
> Centralized place for storage of app-state