Treat them like customers in a bank with the same intent/action of depositing money (type) but different amounts (text). State management is a big concern in large applications and Redux solves this problem. Some nice things you can do with Redux are logging, hot reloading, time travel, universal https://deveducation.com/ apps, recording, replay, etc. The Provider component takes in the store as a prop and passes it down to all the child components that need access to it. The export statement exports the generated action creators, which can be used in other parts of your app to dispatch actions to the slice.

what does redux do

Now reducer looks at the action and accordingly does what it needs to do for storing the data in the store. It comprises a switch case state, which stores data and returns updated state value from the store. The value in the store update every time the state shows some fluctuations. The store can secure the state efficiently and holds the app state as well.

What Are Reducers in Redux?

Even if you don’t do this often, you’re likely aware of what the process looks like. Since a 5-year old doesn’t have the time for technical jargon, I’ll keep this very simple but relevant to our purpose of learning Redux. These things will likely sound fancy until you use them and see for yourself. I have built apps in production that don’t use Redux. As you develop React applications, you may find that keeping all your state in a top-level component is no longer sufficient for you.

It is a common practice to have the major actors of a redux app live within their own folder/directory. Hopefully you now understand how I came up with the actions. By switching over the action.type what does redux do , we can handle both actions without hassle. So, in this example, both action #1 and action #2 will pass through the same reducer. In a Redux app, every action flows through the reducer.

Making the Reducer Count

HandleChange in turn dispatches the setTypingValue action we created earlier. This time, passing the required payload, e.target.value. As we proceed, I’ll explain what a “pure” reducer means. Most people know that the Mediterranean diet is one of the healthiest eating plans because it’s chock full of fruits and vegetables. But many experts say the underappreciated secret sauce in the diet is its liberal use of extra virgin olive oil as the primary added fat.

what does redux do

As we mentioned earlier, Redux is a standalone library that can be used with different JavaScript frameworks including Angular, Inferno, Vue, Preact, React, etc. This helps you restrict any part of the view or any network calls to write/update the state directly. In this article, we’ll be covering the fundamentals of Redux. We will learn what Redux is at its core along with its three key principles. If we dig deeper into this statement, we see that Redux is a state management library that you can use with any JS library or framework like React, Angular, or Vue.