Why don't you have to include 'thunkAPI' as an argument in createAsyncThunk's async when the function has no params?

Question about Redux. Sorry if this isn’t the right place to ask, couldn’t find a redux specific thread.

In Redux’s createAsyncThunk I understand the second argument is an asynchronous payload creator. Please correct me if any of this is wrong. But if there’s any parameters, the arguments for async is supposed to be your param name and then ‘thunkAPI’, like so:

const fetchUserById = createAsyncThunk(‘users/fetchUserById’, async (id, thunkAPI) => {//code}

If you pass in a param for ‘arg’, you always have to include ‘thunkAPI’ as the second argument, right? However, if you don’t have a param you’re passing into async you don’t have to include the thunkAPI part of the argument?

The lesson was unclear with this, stating, " If your thunk requires no arguments, you can just call your thunk action creator without, and the arg argument will be undefined."

So you don’t include ‘thunkAPI’ if you’re not passing any params into your function? If so, I’m curious why you don’t need to since thunkAPI is an object containing all of the parameters that are normally passed to a Redux thunk function, like dispatch and getState.

Thank you very much for any help


Did you ever get an answer to this?

I’m also stuck with this! The exercise doesn’t go into enough detail on thunks, and I’m now working on the Reddit app project, and totally lost with this aspect.