Skip to content

Commit a9adf6d

Browse files
committed
Update createAsyncThunk.mdx
1 parent e9ad9ce commit a9adf6d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/api/createAsyncThunk.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ type RejectedWithValue = <ThunkArg, RejectedValue>(
212212
213213
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)):
214214
215-
```ts {2,6,14,23}
215+
```ts no-transpile {2,6,14,23}
216216
const reducer1 = createReducer(initialState, {
217217
[fetchUserById.fulfilled]: (state, action) => {},
218218
})
@@ -246,7 +246,7 @@ const reducer4 = createSlice({
246246

247247
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:
248248

249-
```ts
249+
```ts no-transpile
250250
const onClick = () => {
251251
dispatch(fetchUserById(userId)).then(() => {
252252
// do additional work
@@ -346,7 +346,7 @@ If you need to customize the contents of the `rejected` action, you should catch
346346

347347
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.
348348

349-
```ts
349+
```ts no-transpile
350350
const updateUser = createAsyncThunk(
351351
'users/update',
352352
async (userData, { rejectWithValue }) => {
@@ -590,7 +590,7 @@ const UsersComponent = () => {
590590

591591
_Note: this is a contrived example assuming our userAPI only ever throws validation-specific errors_
592592

593-
```ts
593+
```ts no-transpile
594594
// file: store.ts noEmit
595595
import { configureStore, Reducer } from '@reduxjs/toolkit'
596596
import { useDispatch } from 'react-redux'

0 commit comments

Comments
 (0)