why redux is used

Over the past 3 months, I have been working exclusively with React-Redux to build a web application. Initially the learning curve was steep. I had to get more familiar with javascript, learn React-Redux, and get familiar with an existing codebase. Working in an existing codebase as a novice can be a gift and a curse. It is easy to cherry pick code and piece together functionality, however it can slow down your understanding of how the code works and its intent. With that in mind, I decided to start a series of posts to explain the React-Redux concepts I struggled with.

After reading this post you will understand why Redux is used in conjunction with web frameworks and libraries like React.

Why Redux?

Now if you are like me, you may be thinking “Ok...Redux maintains the state of your app. Can’t I just manage the state of my app using React”?  Yes, you can manage the state of your app without using Redux. Inside of your component you would create a state object that looks similar to this:


Class App extend Component {

   state = {

       name: ‘Vincent Sanders’

   }

   render () {

       …

   }

}

Now imagine working in a large codebase, where you have multiple components that may need to share various parts of your state. You will have to create a parent component, that is an ancestor to the associated child components, that maintains the state and passes the state down to the child components as props. As you add new features to your codebase, maintaining the state of your application within components can become a large task. This is where the value of Redux is realized.

Redux Value Proposition

Redux simplifies the state management process within your web app as there is only one state object for the entire app. Having a one central location to manage state removes the need for components to manage their own state. Redux stores are immutable and simplify testing and debugging within your application.

Have more questions about React-Redux? Contact us or checkout our other posts about React-Redux.

React-Redux for Newbies: Why Redux is used
Tagged on: