Redux vs plain React

utxeee :

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?

markerikson :

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Uncaught Error: Actions must be plain objects (React/Redux)

Actions must be plain objects. React-redux error

redux-react error: Actions must be plain objects

React Redux sync action return error when giving plain object

Error in React Redux: Unhandled Rejection (Error): Actions must be plain objects

React redux - passing parameters to url - error - Actions must be plain objects

Easy Peasy VS React Redux

React Hooks Vs React-redux

React Native - What is the benefit of using StyleSheet vs a plain object?

React with redux and component vs. container dilemma

React JS and Redux: useSelector() vs useStore()

React vs Redux props on the 'constructor' and 'super'

redux vs this.state in react native

Relay vs Redux vs Apollo with GraphQL and React-Native

React props vs redux vs hooks and context api

SingleThreadExecutor VS plain thread

ForkJoinPool vs Plain Recursion

Plain text vs binary

Encapsulation Vs Plain

Error: Actions must be plain objects. Use custom middleware for async actions. React-redux error

React-Redux: Actions must be plain objects. Use custom middleware for async actions

"Actions must be plain objects. Use custom middleware for async actions." with react/redux

React/Redux... Error: Actions must be plain objects. Use custom middleware for async actions

Actions must be plain objects. Use custom middleware for async actions- React Native Redux

React-Redux-Saga: Actions must be plain objects. Use custom middleware for async actions

Actions must be plain objects. Instead, the actual type was: 'undefined'. React-Redux

React Redux Saga: Actions must be plain objects. Use custom middleware for async actions

react-redux Error: Actions must be plain objects. Use custom middleware for async actions

React/Redux: Error: Actions must be plain objects. Use custom middleware for async actions