Skip to content
Advertisement

Expected 0 arguments, but got 1 in redux with typescript

So I have an async thunk function in redux:

JavaScript

And here is my fetch function in react, it fetches the item by the html id of the event target (an tag):

JavaScript

The error is in the fetchItem and it says: Expected 0 arguments, but got 1. I even tried just using:

JavaScript

And got the same error.

useAppDispatch looks like this:

JavaScript

Advertisement

Answer

  1. useAppDispatch is a hook and can be used only directly inside component’s body
  2. useAppDispatch takes 0 arguments, but you pass 1
  3. useAppDispatch returns a dispatch function that you wanted to use
JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement