📜 ⬆️ ⬇️

ReactJS year of use: sum up

React we love and appreciate in Voximplant. It’s not because of HYIP (one and a half thousand tweets about the new SDK, simply because it is React Native), but because the framework is really convenient. Simply splitting up the interface into small isolated pieces is something that Jade / Pug, Web Components, and even Angular lacked so much.

Under the cut, an adapted translation of an article in which the developers of JetRuby Agency share their impressions of React: what they used, what they didn’t use and what they are still planning to use.


Almost a year has passed since we began to apply ReactJS and digest a sea of ​​related technologies. And we are here to share our experience with you.
')
We recently completed a project that used client-side rendering and a Rails API server. The overall impression is deeply positive.

What we liked:


Naturally, in this new beautiful world, not everything is so beautiful. We still encountered a number of problems:


Several technical solutions that seem right to us and which we want to recommend:


What we want to try in the following application:

Use babel

Babel is already officially used by React to work with JSX. But, even if you do not use JSX, Babel is still an excellent tool for front-end development. Who does not want to use all these cool features of ES6 and ES7, without waiting for their support in browsers?

Isomorphic applications

Right now it's a trend. If you have not heard of this approach yet , here is a good overview from the Airbnb team. The idea is to render the HTML page on the server, transfer it to the client (with caching and CDN) so that it is instantly displayed in the browser, and then when JavaScript loads, ReactJS will “pick up” to the already rendered page and the application will “come to life”.

Use Functional Reactive Programming (FRP) to coordinate (as a Flux Dispatcher)

There are some good libraries for using FRP in JavaScript (RxJS, Bacon, Kefir). The basic idea is to present variables as a sequence of changes, and combine these changes using functions such as map , filter , reduce, and higher-order functions (a function that takes another function as an argument). For the user interface, this approach makes it possible to convert a sequence of events into a stream of events and manipulate such flows as objects.

One stop for state management

Gives only one, but a huge advantage. Since there is no local state in the components of React, we can consider the UI as one pure function (a term from functional programming) that receives one input state as an argument and returns the user interface (more precisely, its React representation) corresponding to this state. In practice, this approach allows for real-time debugging, undo and redo, time travel. Here you can see how it's all done:


This approach takes testing and debugging of web applications to a completely new level. No longer need screenshots and a long list of “playback steps”. If you encounter a bug, simply copy the current state of the application and give it to the developers.

Immunity data structures

In some cases, their use allows you to write faster code. In which, moreover, there will be fewer bugs due to the absence of mutable objects and values. Despite the fact that Baobab does not offer immutable data structures (only persistent), he does not recommend directly changing the data tree, but suggests using API functions for this.

Image author (in front of the cut) - Stefpet , reative Commons 2.0 .

Source: https://habr.com/ru/post/308118/


All Articles