In this section, we will learn about the Thunk pattern and how to use it with the Redux Thunk library. To begin, we will need to refactor our naive and faulty implementation from the previous section to one using Redux.
The Thunk pattern and Redux Thunk
Lifting the state to Redux
Instead of relying on the component state, let's lift it to a Redux store. Pay attention to the Immutable.Map we use here. Also, the ADD_TASK action is now using the update function from Immutable.js:
// src / Chapter 6 / Example 3 / src / reducers / taskReducer.js
const taskReducer = (state = Immutable.Map({
entities: Immutable.List([]),
isLoading: false,
hasError: false,
errorMsg: ''
}), action) => {
switch (action...