Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update part-5-async-logic.md #4747

Merged
merged 2 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/tutorials/essentials/part-5-async-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ import { createSlice, nanoid } from '@reduxjs/toolkit'
// highlight-start
interface PostsState {
posts: Post[]
status: 'idle' | 'pending' | 'succeeded' | 'rejected'
status: 'idle' | 'pending' | 'succeeded' | 'failed'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to follow the AsyncThunk types pending, fulfilled, rejected. Nevertheless switching back to failed we have to correct it here in the docs otherwise the reader is confused.

error: string | null
}

Expand Down Expand Up @@ -1026,6 +1026,12 @@ const postsSlice = createSlice({
// highlight-end
}
})

// highlight-start
// Remove `postAdded`
export const { postUpdated, reactionAdded } = postsSlice.actions
// highlight-end

```

### Checking Thunk Results in Components
Expand All @@ -1052,10 +1058,11 @@ import { addNewPost } from './postsSlice'
// omit field types

export const AddPostForm = () => {
// highlight-next-line
// highlight-start
const [addRequestStatus, setAddRequestStatus] = useState<'idle' | 'pending'>(
'idle'
)
// highlight-end

const dispatch = useAppDispatch()
const userId = useAppSelector(selectCurrentUsername)!
Expand Down