Skip to content

Commit 77e0602

Browse files
Update part-5-async-logic.md (#4807)
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.
1 parent 6e3c35b commit 77e0602

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/tutorials/essentials/part-5-async-logic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ As a reminder, here's what we covered in this section:
11281128
- Thunk functions receive `dispatch` and `getState` as arguments, and can use those as part of async logic
11291129
- **You can dispatch additional actions to help track the loading status of an API call**
11301130
- 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'`
11321132
- **Redux Toolkit has a `createAsyncThunk` API that dispatches these actions for you**
11331133
- `createAsyncThunk` accepts a "payload creator" callback that should return a Promise, and generates `pending/fulfilled/rejected` action types automatically
11341134
- Generated action creators like `fetchPosts` dispatch those actions based on the Promise you return

0 commit comments

Comments
 (0)