You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the summary part of the document, where it is stated: "Loading state should usually be stored as an enum, like 'idle' | 'pending' | 'succeeded' | 'rejected'". It is important to realize that the example given wasn't a TypeScript enum, but TypeScript's union of string literals. The documentation should be updated to reflect this.
Copy file name to clipboardExpand all lines: docs/tutorials/essentials/part-5-async-logic.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1128,7 +1128,7 @@ As a reminder, here's what we covered in this section:
1128
1128
- Thunk functions receive `dispatch` and `getState` as arguments, and can use those as part of async logic
1129
1129
-**You can dispatch additional actions to help track the loading status of an API call**
1130
1130
- The typical pattern is dispatching a "pending" action before the call, then either a "success" containing the data or a "failure" action containing the error
1131
-
- Loading state should usually be stored as an enum, like `'idle' | 'pending' | 'succeeded' | 'rejected'`
1131
+
- Loading state should usually be stored as a union of string literals, like `'idle' | 'pending' | 'succeeded' | 'rejected'`
1132
1132
-**Redux Toolkit has a `createAsyncThunk` API that dispatches these actions for you**
1133
1133
-`createAsyncThunk` accepts a "payload creator" callback that should return a Promise, and generates `pending/fulfilled/rejected` action types automatically
1134
1134
- Generated action creators like `fetchPosts` dispatch those actions based on the Promise you return
0 commit comments