Flux+React vs Backbone+React [closed] Flux+React vs Backbone+React [closed] reactjs reactjs

Flux+React vs Backbone+React [closed]


Flux is an architect pattern to build React application. So you can use Backbone models and collections inside your stores to fetch and store data.

And if want to use just React's Virtual DOM feature, there is no need to use react.js. There are a lot of libraries, adding Virtual DOM feature to your application (https://github.com/Matt-Esch/virtual-dom).

My recommendation: if you will use Flux pattern I strongly recommend you to use http://facebook.github.io/immutable-js/ (may be coupled with http://ampersandjs.com/; don't forget to define your custom sync function if you are building isomorphic application). Basically there are no any advantages using backbone models with React (backbone is heavy, it needs underscore, which is slow; I use https://lodash.com/ instead ).


IMHO Flux stores are not incompatibles with Backbone models / collections.You can probably use Backbone collections as Flux stores, as long as you integrate them with the Flux dispatcher and you permit them to emit an event to trigger a rendering.

I'm just not sure Backbone models are meant to be immutable data structures in the first place, thus making it harder for React to optimize the rendering.

I would also say that I never really found all these Backbone models/collections methods really useful. In a Flux architecture, API requests would tend to be fired by action creators and not by the stores directly, thus permitting multiple stores to listen to the same request completion.

Where should ajax request be made in Flux app?


One nice thing about React is that it is agnostic - you can use it with Backbone models and collections without problem.

Flux is a suggested architecture, but I think the model diverges so greatly to MVC that at the end of the day it's not worth to try to use them both - Use React with Flux OR React with Backbone models and collections.

I wouldn't recommend using Backbone models/collections as Flux stores - they're not the same thing. Main reason being that a flux store can't be mutated from outside - it doesn't provide setters. A Flux store mutate it's own state in response to actions. And even if you follow the "Flux" way using Backbone models as stores, your code still has open possibilities for direct manipulation of state from outside the store that could be misused by other members of the team, for example...