While working with my Redux async thunks, I encountered a situation where I needed to utilize the AppDispatch type as outlined in this resource: https://redux.js.org/recipes/usage-with-typescript
Following the guidelines provided here: https://redux.js.org/recipes/usage-with-typescript#typing-createasyncthunk
However, incorporating the AppDispatch type within my custom ThunkApiConfig type (MyThunkApiConfig
in the code example) resulted in a circular reference issue demonstrated in this example: https://codesandbox.io/s/focused-joliot-ho45h?file=/src/usersSlice.ts:
'dispatch' is referenced directly or indirectly in its own type annotation.
This dilemma arises from the circular dependency between the dispatch type and the used thunks. I am seeking advice on how to effectively implement AppDispatch within the async thunk functionality. Any insights would be greatly appreciated!