File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ const UsersComponent = () => {
453
453
` ` `
454
454
455
455
- TypeScript: Using rejectWithValue to access a custom rejected payload in a component
456
- _Note: this is a contrived example assuming our userAPI only ever throws a validation-specific errors_
456
+ _Note: this is a contrived example assuming our userAPI only ever throws validation-specific errors_
457
457
458
458
` ` ` typescript
459
459
import { createAsyncThunk , createSlice , unwrapResult } from ' @reduxjs/toolkit'
@@ -527,7 +527,7 @@ const usersSlice = createSlice({
527
527
})
528
528
529
529
const UsersComponent = () => {
530
- const { users, loading, error } = useSelector (state => state .users )
530
+ const { users, loading, error } = useSelector ( ( state : RootState ) => state .users )
531
531
const dispatch = useDispatch ()
532
532
533
533
const updateUser = async userData => {
Original file line number Diff line number Diff line change @@ -504,7 +504,7 @@ const usersSlice = createSlice({
504
504
})
505
505
builder .addCase (updateUserById .rejected , (state , action ) => {
506
506
if (action .payload ) {
507
- // Being that we passed in MyKnownError to rejectType in `updateUserById`, the type information will be available here.
507
+ // Since we passed in ` MyKnownError` to ` rejectType` in `updateUserById`, the type information will be available here.
508
508
state .error = action .payload .errorMessage
509
509
} else {
510
510
state .error = action .error
@@ -525,7 +525,7 @@ const updateUser = async userData => {
525
525
showToast (' success' , ` Updated ${user .name } ` )
526
526
} else {
527
527
if (resultAction .payload ) {
528
- // Being that we passed in MyKnownError to rejectType in `updateUserById`, the type information will be available here.
528
+ // Since we passed in ` MyKnownError` to ` rejectType` in `updateUserById`, the type information will be available here.
529
529
showToast (' error' , ` Update failed: ${rersultAction .payload .errorMessage } ` )
530
530
} else {
531
531
showToast (' error' , ` Update failed: ${resultAction .error .message } ` )
You can’t perform that action at this time.
0 commit comments