---
# System prepended metadata

title: '2001-GHP Cookie Jar: Redux Day 3: Thunks, combineReducers, Loading State'

---

# 2001-GHP Cookie Jar: Redux Day 3: Thunks, combineReducers, Loading State

Put your pending and outstanding questions here 👇
Make the question in H2 tag by using '##'

## Why do we have to invoke the thunk in mapDispatch, and then invoke the mapped dispatch again in componentDidMount?
(from the Thunk Middleware lab)
![](https://i.imgur.com/ijNmOPN.png)


![](https://i.imgur.com/oazgNsN.png)


### Answer

I did the same thing in the live code. What the first image is saying is: we are going to return an object that contains a key value pair where the key is the name of the function and the value is an anonymous function that calls `dispatch`. This will map that function "getPets" to our component's `props` object

The second image is saying invoke that function that is attached to our `props` when `componentDidMount` runs

## In the pokemon example within the mapDispatch function the getPokemon method takes pokemon as an argument. Why is this? It doesn't look like it's used in the thunk method in store.js. . . . 

```const mapDispatch = (dispatch) => ({
  getPokemon: (pokemon) => dispatch(getPokemon(pokemon))
})
```

### Answer

I like to call this "dream typing" where I am just typing really quickly not realizing I typed something wrong. So, the pokemon parameter here isn't needed in this case. However, if our `thunk` needed some extra data, we can use that variable. I apologize

### (From Ben) On that same note from above

I made a mistake in the lecture with the `try/catch` block in the `thunk`. I mistakenly put `next` but that wouldn't work because firstly, we were not in Redux middleware and secondly, it doesn't know what `next` is. Don't use the `next` in the `catch` block. Just `console.log` or `console.error` it. I apologize. I wasn't sure where my mind was at. This is why you run and test your code! I didn't run it after I said you can `try/catch` it. 😄😅