javascriptreactjssails.jsflux

Is Flux a library which operates as the backend for React?


I'm very new to the React and Flux consept and I'm confused as hell..

I come from a background of Sails.js so I can't really tell whats what with React.

I plan to use Sails.js (as a restful api, isolated from the front end) + React (as my front end using restful calls + perhaps websockets to communicate with sails)

but I don't see where flux fits in!


Solution

  • Flux is definitely not a requirement for using React and does not operate as a "back-end" for React. It's just a common pattern for structuring applications written with React. It's well documented here.

    It is only a client side solution. It does not have a hard requirement on any particular web server (but it is convenient if you have NodeJS installed so that you can use something like Browserify to compile and package scripts).

    It's not clear from your question what parts of Sails you're planning to use. If you want to use React in an isomorphic way (meaning you'd run React code on the web server and it would be then "attached" by the React client code, without re-rendering), then data management could be an issue if you're using Waterline. But, if you're only going to use React on the client, then it may be an easier integration.

    But, again, it's not necessary to use Flux. You can just follow the basic principles of using React JS regarding data flow (parent to child) and use other data storage and synchronization libraries. React is not opinionated that way.

    Also, while Facebook has a Flux implementation here, you'll find dozens of implementations of the pattern with various tweaks and enhancements located here. You'll also note on that same page that there are lots of other complimentary libraries that may be useful.