39

I have been reading some redux tutorials and to be honest I do not see up until now what added value it brings over plain react.

As far as I know I can build an app and manage its state using only react, so, what makes redux something worth using?

Well, I do recognize redux has a few advantages over react, namely:

  • Keeps track of all the actions carried out;
  • Makes it easier for debugging due to the previous point;
  • Prevents state from being passed down/up between components.

But maybe due to my lack of experience building large apps I am not convinced that it would make my life easier.

Can you elaborate a little more on the advantages of using redux over plain react?

6
  • react and redux serve wholly different purposes in an application. keep reading.
    – Bosworth99
    Sep 1, 2016 at 0:01
  • With redux your life may become easier. Or the opposite. Just try and decide yourself whether you like it or not.
    – zerkms
    Sep 1, 2016 at 0:09
  • Ultimately I feel like it depends on the scope of your project. Although I am no expert it seems like you can easily create a complex application without needing any sort of flux implementation...
    – Maxwelll
    Sep 1, 2016 at 2:02
  • 1
    The clear advantage is maintainability. See: redux.js.org/docs/introduction/Motivation.html Sep 1, 2016 at 3:53
  • 1
    Thank you for your input, it will be certainly quite valuable despite this question being put on hold. I really think this is a common question that will help a lot of people in the future.
    – utxeee
    Sep 1, 2016 at 10:04

2 Answers 2

41

Off the top of my head, a few advantages:

  • A lot of the time your app's state tree could be considerably different than the UI tree
  • Many components may need to access the same state and display it in different ways
  • Hot reloading components will wipe out your existing component tree, including any state stored inside of them. Keeping the state separate from the UI tree allows the UI tree to be swapped out and reloaded with the updated components, while keeping your current development state the same.

And that's before getting to many of the commonly discussed benefits, such as predictable state updates, time travel debugging, improved testability, and centralized logic.

It's certainly true that you can write an entire application using nothing but React's component state (and Dan Abramov himself says that people often jump into Redux too early), but from my perspective Redux is absolutely worth it.

edit

I've written up an expanded version of this answer as an article on the Full Stack React site: Redux and Why It's Good For You.

0
10

To me, the biggest advantage is the fact that redux has a single state tree compared to possibly many smaller states in react only components. Together with redux' reducers, state becomes very deterministic and is easier to reason about.

6
  • 5
    You can have a single state hosted by the root component even without redux.
    – zerkms
    Sep 1, 2016 at 0:03
  • 1
    That is why I said "possibly". Managing a single state in react is more cumbersome than in redux IMO. Sep 1, 2016 at 0:04
  • "That is why I said "possibly"", "IMO" --- that's what makes the answer and question subjective. IMO - there is no much difference.
    – zerkms
    Sep 1, 2016 at 0:05
  • 1
    If you disagree, please feel free to answer the question yourself and down-vote mine. I appreciate your feedback. Sep 1, 2016 at 0:07
  • 1
    None taken. I think we can all benefit from opinions of highly decorated veterans like you. Sep 1, 2016 at 0:09

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