Summary
In this chapter, we learned that the state in a Redux store is stored in a single place, is read-only, and is changed with a pure function called a reducer. Our components don't talk directly to the reducer; instead, they dispatch objects called actions that describe the change to the reducer. We now know how to create a strongly typed type Redux store containing a read-only state object with the necessary reducer functions.
We learned that React components can access a Redux store if they are children of a Redux Provider
component. We also know how to get state from the store from a component using the useSelector
hook and create a dispatcher to dispatch actions with useDispatch
as the hook.
There are lots of bits and pieces to get our heads around when implementing Redux within a React app. It does shine in scenarios where the state management is complex because Redux forces us to break the logic up into separate pieces that are easy to understand and maintain...