- There is an entire library, called react-redux whose sole purpose is to seamlessly integrate redux’s state management into a React application.
- Lets take a look at redux’s state management flow :
If you have worked with redux before, you know that its functionality revolves around a “store”, which is where the state of the application lives.
- Now, let’s come to the (simplified) component structure of a standard react todo-mvc application :
If we want to link our React application with the redux store, we first have to let our app know that this store exists.
- However, because of the utility that gives us, I feel it’s more appropriate to represent it as something which “wraps” the entire application tree, like this :
Now that we have “provided” the redux store to our application, we can now connect our components to it.
- We can either retrieve data by obtaining its current state, or change its state by dispatching an action (we only have access to the top and bottom component of the redux flow diagram shown previously).
Redux is a terribly simple library for state management, and has made working with React more manageable for everyone. However, there are a lot of cases where people blindly follow boilerplate code to integrate redux with their React application without understanding all the moving parts involved.
Continue reading “React-redux “connect” explained 🔗”