Poor types for createAsyncThunk
See original GitHub issueCurrently attempting to type parts of createAsyncThunk to not have repeated code within the action.
Currently there are many issues open with attempting to extend the function or wrap it. I have seen some good examples but no solid way to type the thunk api that is passed into the createAsyncThunk.
My current issue is that I am unable to even type the function rejectWithValue
since the type RejectWithValue
type isn’t exported I am unable to type a custom function to take that type of a function. Let alone trying to type the thunkApi parameter itself which has many many unexported types that make it up.
Please export the types
Issue Analytics
- State:
- Created a year ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
What are some common Redux Toolkit's CreateAsyncThunk ...
Well you can divide Async Thunk functions and Reducer functions into a separate types. They aren't exactly the same and you should notice ......
Read more >typeActionCreator is undefined for createAsyncThunk.withTypes
withTypes<AsyncThunkConfig>() in order to have types available in my slices. Expected behaviour: I expected to be able to access the ThunkApi ...
Read more >createAsyncThunk - Redux Toolkit
A function that accepts a Redux action type string and a callback function that should return a promise. It generates promise lifecycle action ......
Read more >Reasoning behind using Redux Toolkit's createSlice ... - Medium
Reasoning behind using Redux Toolkit's createSlice and createAsyncThunk to handle your asynchronous state changes.
Read more >Does it make sense to use createAsyncThunk if you aren't ...
I wrote a thunk using `createAsyncThunk` which takes a single argument, fetches some other data from my store using the `getState` param, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sure - could you try filing a PR to update the docs with the info you’d like to see added?
Probably you want to write something like
You don’t need all the properties of
thunkApi
typed correctly for that. For your function, all that matters is that it receives an object with arejectWithValue
function on it that accepts a string, and that your function will return whatever thatrejectWithValue
returns.