React Redux in a Nutshell
I have been working some old projects recently. I realized now that my knowledge of Redux was pretty surface level at best so I wanted to get dive in a bit deeper to feel a bit more comfortable with Redux going forward. Today, I want to give a broad overview of Redux so you may not be as lost when you are either just learning it or trying to refresh yourself.
First off, what is Redux? a very basic way to put it would be to say that it is a pattern and a library for updating state across the entire application. Instead of passing down state from parent to child, you are able to manipulate state in a child component and share it across all of the application. This can be extremely helpful in many cases. One use I found for it was having an object be created from accessing the state of three others. Because I can share state across my application, it allowed me to edit these states to curtail the combined object I was creating.
What is the store? Though it isn’t a wild concept, it is important to grasp. The store is the container that houses the global state. Just like local state, you should never directly manipulate the global state. Instead, you should dispatch actions to alter state. The action should go through a reducer which will calculate the new state. The reducer takes two arguments, the first is the original state. The second is the action.
Understanding the most basic principles is key. I wanted to keep this as surface level as possible because there are so many great resources out there to dive a bit deeper. I know it can be a bit overwhelming at first but once you can start to master this, you will find that it saves a lot of time and headache in your applications. As always, happy coding friends.