Ad

ReactJs In AngularJs

- 1 answer

As I don't know anything about React jet, I am wondering, what are the main benefits of introducing React in Angular's directives and what are down sides?

Basically I am working on some complex software with lot's of renderings in one cycle. Obviously I already excluded ngRepeat, etc. but I am wondering if React can speed up rendering in this case even further?

Is react better only in rendering lot's of element's or is it better in rendering of small amount of them as well?

Ad

Answer

That's a subject I've studied at work and here are my conclusions about adopting an hybrid solution (AngularJS 1.x and React) :

Pros :

  • best of both worlds (speed, testability, a lot of convenient things already are implemented in AngularJS — $http, $cookies, whatever)
  • probably forces to uncouple more and more the code. Since the two worlds can't really share components/services, you'll have to adopt a nice architecture which will lilely makes the two parts easy to plug/unplug. Say you wanna use Angular2 components after all, a lot of uncoupling work will already be done.

Cons :

  • You'll have to glue stuff together. The glue code can end being more complicated than expected
  • You'll have to load two frameworks/libs. Although that might not be a problem for SAAS apps, it can very well be for regular websites with a lot of unique visitors.
  • You'll have to learn another framework (should that be in the "Pros" section ?)
  • Maintainance bad smell : the less different technologies, the better
  • An overall more complicated stack

In the end I think that if you don't absolutely need React, try to implement your component in regular JavaScript to avoid excessive $apply cycles. It's cleaner in my opinion.

Ad
source: stackoverflow.com
Ad