0

I heard that AngularJS is becoming quite popular, and at the same time ReactJS is also. But if AngularJS already takes care of MVC with 2 way binding between model and view, would ReactJS actually be needed?

I thought ReactJS is binding model to view, but not binding view to model (say, if it is a form text input field, if the value change, it won't go to the model?) In fact, ReactJS seem to do what CanJS was doing, by reflecting what the model is by building a template, and whenever the model changes, the view is automatically updated -- there is no need to do anything at all. But doesn't AngularJS already do that?

1 Answer 1

3

AngularJS is a full-featured front-end framework. It takes care of the three parts of MVC, plus the structure of the overall application (dependency injection, routing, ajax, etc.). You don't need React for Angular. You actually don't need anything else than Angular.

ReactJS is a specific library for the "V" part of MVC. It's only about the view. If you don't need anything else, just use React. If you need routing, ajax, events handling, etc., the philosophy of the React/Flux stack is to use specialized libraries for that (react-router, some Flux implementation, Immutable.js, etc.).

These are two different approaches. You can replace Angular's directives with React's components, thus using Angular for the "MC" and React for the "V", and there are some benefits of this (mostly performance, also, React components are simpler to reason about than Angular directives).

If you are starting a project with Angular or already using it, just stick to Angular, don't make things more complicated that needed. If you are considering using React, then read about how to structure your application using Flux or a similar approach, because it's going to be completely different than Angular. Then choose the one you like the most (knowing that Angular2 is coming, with a design that is closer to that of Flux/React).

4
  • you don't need anything besides AngularJS? I think I have seen people use Twitter's Bootstrap with Angular... but maybe it is optional Jan 8, 2016 at 14:24
  • @太極者無極而生 Twitter Bootstrap is a CSS and UI element library. Angular is a single page app framework which provides routing and data binding (along with a bunch of other stuff). Bootstrap speeds the pretty page layout while angular speeds logic development. bootstrap is indeed optional but the gains of not having to write all the CSS your self make it very helpful. This SO answer has more info stackoverflow.com/a/17780006/3302585 Jan 8, 2016 at 14:36
  • Yeah well you will probably need a few other libraries for components and utilities, but that's a constant in js, regardless of the solution you go with. This has nothing to do with choosing what approach to use to implement an MV* application, which is - I think - what this question is really about.
    – kjaquier
    Jan 8, 2016 at 14:49
  • @kjaquier AngularJS is more a DI based framework like spring with additional default capabilities : templating, routing, ... It's goal is first to be able to integrate any components easily and in a standard way. As such you can integrate specialized library in angular and make them available through injection. But yes using React seems redondant, unless you have some specific reason to do so.
    – Walfrat
    Sep 12, 2017 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.