S
S
Silent_272015-04-17 16:53:27
JavaScript
Silent_27, 2015-04-17 16:53:27

Where is the best place to use ReactJS?

I see people are starting to include this library in production development, there is even a platform for building mobile applications. Even going to their main page - they say that React acts as V in your MVC, but for example, I write in angular and linking it with react would be extremely unethical, but then I wonder - with which frameworks or libraries it can be used in conjunction, as I understand it, it can be rendered on the server, of course I write in NodeJS, but so far I have not used this practice, I would like to know how effective it is and in what tasks. In general, please tell us more about those who used it in commercial development.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Roman Yakovlev, 2015-04-18
@feligz

ReactJs can be used in conjunction with Flux (there are options like Reflux). Flux is an architecture for building complex applications, and it also provides a set of methods for organizing this architecture.
Where to apply. Definitely where you need to process a large amount of data in real time. Rendering on React is still the fastest of all frameworks.
React is simpler than Angular and Ember, for example, runs natively on components, with templates already built into components, which can be quite handy. Component architecture is generally the future and the second version of Angular is slowly moving in the same direction. There are so-called mixins, ready-made components that can already be built into the application. There is a routing. In general, of course, Angular is more of a feature complete, a huge army of developers is constantly adding something, and the team itself is actively working on the framework. In addition, a bunch of tutorials and ready-made solutions make Angular the best universal solution for the entire frontend today.

A
Alexander Reshetnyak, 2015-04-23
@Vampireos

completely forgot about ru.matreshka.io ( ' ')/
..maybe easier in conjunction

S
smanioso, 2015-04-17
@smanioso

I recommend to look:
isomorphic.net
davidchang.github.io/ngReact
https://github.com/facebook/react/wiki/Complementa...
https://andywalpole.me/#!/blog/142134/2015-the- end...
After that, make your own decision based on personal preferences.
PS: if you really like Angular so much, then maybe you should pay attention to its logical continuation in the form of Angular 2.0? EMNIP, in it View is based on a more correct concept of WebComponents.

M
Max Sysoev, 2015-04-23
@ColCh

I applied. What specifically are you interested in?
Works in conjunction with Express. The rendering itself is middleware. We call the parent component in the script (in my case, this is a router), set the context - data from the database, URL, draw the component into a static markup line and display this line. It's simple :)
For the router I use react-router
Below is copy-paste from the project:

var getMarkup = function (req, data) {
    return new Promise(function (res, rej) {

      var location = req.url;
      Router.run(routes, location, function (Handler, state) {
        var isNotFound = detectNotFound(state);
        if (isNotFound) {
          rej();
        } else {
          var handler = React.createElement(Handler, {flux: flux, data: data});
          var markup = React.renderToString(handler);
          res(markup);
        }
      });

    });
};

In fact, the most important lines are:
var handler = React.createElement(Handler, {flux: flux, data: data});
var markup = React.renderToString(handler);
res(markup);

hander - the React component that resulted from the requested
flux URL - in my case it is Fluxxor (its object is placed in the root component and goes through the whole tree through the context)
data - a JSON object with data. The data is taken from the database.
Link to the project that helped me understand this all: react-isomorphic-video-game-search

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question