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
Copy file name to clipboardExpand all lines: docs/api/createAsyncThunk.mdx
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -212,7 +212,7 @@ type RejectedWithValue = <ThunkArg, RejectedValue>(
212
212
213
213
To handle these actions in your reducers, reference the action creators in `createReducer` or `createSlice` using either the object key notation or the "builder callback" notation. (Note that if you use TypeScript, you [should use the "builder callback" notation to ensure the types are inferred correctly](../usage/usage-with-typescript.md#type-safety-with-extrareducers)):
Thunks may return a value when dispatched. A common use case is to return a promise from the thunk, dispatch the thunk from a component, and then wait for the promise to resolve before doing additional work:
248
248
249
-
```ts
249
+
```ts no-transpile
250
250
const onClick = () => {
251
251
dispatch(fetchUserById(userId)).then(() => {
252
252
// do additional work
@@ -346,7 +346,7 @@ If you need to customize the contents of the `rejected` action, you should catch
346
346
347
347
The `rejectWithValue` approach should also be used if your API response "succeeds", but contains some kind of additional error details that the reducer should know about. This is particularly common when expecting field-level validation errors from an API.
0 commit comments