Redux vs plain React [closed] Redux vs plain React [closed] reactjs reactjs

Redux vs plain React [closed]


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.


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.