Why use Redux over Facebook Flux? [closed]

clock icon

asked 1 month agoVotes

message

2Answers

Views

5Views

I've read this answerreducing boilerplate, looked at few GitHub examples and even tried redux a little bit (todo apps).

As I understand, official redux doc motivations provide pros comparing to traditional MVC architectures. BUT it doesn't provide an answer to the question:

Why you should use Redux over Facebook Flux?

Is that only a question of programming styles: functional vs non-functional? Or the question is in abilities/dev-tools that follow from redux approach? Maybe scaling? Or testing?

Am I right if I say that redux is a flux for people who come from functional languages?

To answer this question you may compare the complexity of implementation redux's motivation points on flux vs redux.

Here are motivation points from official redux doc motivations:

  1. Handling optimistic updates (as I understand, it hardly depends on 5th point. Is it hard to implement it in facebook flux?)
  2. Rendering on the server (facebook flux also can do this. Any benefits comparing to redux?)
  3. Fetching data before performing route transitions (Why it can't be achieved in facebook flux? What's the benefits?)
  4. Hot reload (It's possible with React Hot Reload. Why do we need redux?)
  5. Undo/Redo functionality
  6. Any other points? Like persisting state...

2 Answers

I'm an early adopter and implemented a mid-large single page application using the Facebook Flux library.

As I'm a little late to the conversation I'll just point out that despite my best hopes Facebook seem to consider their Flux implementation to be a proof of concept and it has never received the attention it deserves.

I'd encourage you to play with it, as it exposes more of the inner working of the Flux architecture which is quite educational, but at the same time it does not provide many of the benefits that libraries like Redux provide (which aren't that important for small projects, but become very valuable for bigger ones).

We have decided that moving forward we will be moving to Redux and I suggest you do the same ;)

The user is asking for a comparison between Redux and Facebook Flux. Here are some key points to consider when comparing Redux with Facebook Flux:

1. **Handling optimistic updates**: Redux makes it easier to implement optimistic updates compared to Facebook Flux. Redux's architecture simplifies managing state changes and asynchronous actions, which makes handling optimistic updates more straightforward.

2. **Rendering on the server**: While both Redux and Facebook Flux can support server-side rendering, Redux has a more clear and defined approach to handling server-side rendering. Redux can be integrated with server-side frameworks like Next.js, which provides benefits in terms of performance optimization and SEO.

3. **Fetching data before performing route transitions**: Redux offers a more structured way to handle data fetching before route transitions. It provides middleware like Redux Thunk or Redux Saga that can manage asynchronous data flow seamlessly. While Facebook Flux can also handle data fetching, Redux provides a more organized way to do so.

4. **Hot reload**: React Hot Reload allows for real-time updates in components during development. Redux complements this feature by providing a predictable state container that works well with hot reloading. The separation of logic and state management in Redux makes it easier to maintain the application's state during hot reloading.

5. **Undo/Redo functionality**: Redux supports undo/redo functionality natively through features like middleware and reducers. While it's possible to implement undo/redo in Flux, Redux's design promotes a more straightforward approach to managing undo/redo actions.

6. **Persisting state**: Redux has support for persisting state to local storage or using middleware like Redux Persist. This feature simplifies state persistence across browser refreshes or session reinitializations. While Facebook Flux can achieve state persistence as well, Redux provides a more standardized way to handle it.

In summary, Redux offers a more structured and predictable approach to state management compared to Facebook Flux. It provides additional features and middleware that enhance the developer experience and make handling complex state logic more manageable. The decision to use Redux over Flux may depend on the project requirements, complexity, and the developer's familiarity with each architecture.

Write your answer here

Top Questions