As a developer with good hands-on AngularJS experience, how do I adjust my mental model of writing web apps in Flux using React?
I'm not looking for a Flux+React vs Angular answer (already plenty of that online), but I would like to know what are the biggest differences in the two "mindsets": beforehand, I was introduced into The Angular Way; comparatively, what is The React Way ?
As I leave the Angular universe and transition to Flux, what are the key things I need to start paying attention to?
Differences first, and now similarities: AngularJS is very opinionated and had some very big no-no's, like - don't put UI/DOM code in controllers. What are the big no-no's and opinions of React?
Last but not least, Facebook refers to Flux as an alternative to MVC, but as I am looking at it - React is the view engine, stores are model containers focused on a single domain, and the dispatcher and actions form a controller. So isn't this actually MVC with a different name?
Making the switch from Angular to React requires a mindset change that can be difficult and time consuming. These frameworks take fundamentally different approaches to frontend development.
Yes you can use both, take a look at ngReact, let's you run React components in an Angular app. If you start from scratch however and don't have legacy code or libs written in one of the two technologies, my recommendation would be to either use one or the other.
Conclusion- angular js vs react js which is betterFor less-experienced developers, ReactJS may be a safer bet due to its relative simplicity; however, AngularJS development offers a comprehensive solution to front-end development that could benefit large-scale projects.
I'll let others do the compare/contrast with Angular, but here are some answers to two of your questions.
So isn't this actually MVC with a different name?
The presence in Flux of a separation of concerns between the data/logic layer and the view layer does not make it MVC. Many other patterns have a similar split, most notably CQRS, arguably Flux's closest cousin. There is no controller in Flux, in the MVC sense. The Actions and Dispatcher do not amount to a controller. The Controller-views are close, but are actually quite limited in their controller-like aspect. A key difference is that MVC controllers contain application logic and act upon models. Flux stores, by contrast, contain all the application logic and have no setters.
As I leave the Angular universe and transition to Flux, what are the key things I need to start paying attention to?
Key values of Flux:
Key concepts in Flux:
waitFor()
method. This allows one store to wait for another store's response to an action before moving forward with its own response.Primary parts of a Flux application:
Overview, in depth: http://facebook.github.io/flux/docs/overview.html
Tutorial: http://facebook.github.io/flux/docs/todo-list.html
Examples: https://github.com/facebook/flux/tree/master/examples
Actions and the Dispatcher: http://facebook.github.io/react/blog/2014/07/30/flux-actions-and-the-dispatcher.html
Testing: http://facebook.github.io/react/blog/2014/09/24/testing-flux-applications.html
More out in the wild: http://facebook.github.io/react/blog/2014/10/17/community-roundup-23.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With