Skip to content

Commit

Permalink
Fix statement on Checking Async Thunk Conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
leontalukdar committed Jan 17, 2025
1 parent ba47210 commit eb25450
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/tutorials/essentials/part-5-async-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ The last option would be to use the actual `state.posts.status` value from the R

`createAsyncThunk` accepts an optional `condition` callback we can use to do that check. If provided, it runs at the start of the thunk call, and it will cancel the entire thunk if `condition` returns `false.`

In this case, we know that we want to avoid running the thunk if the `state.posts.status` field is `'idle'`. We already have a `selectPostsStatus` selector that we can use here, so we can add the `condition` option and check that value:
In this case, we know that we want to avoid running the thunk if the `state.posts.status` field is not `'idle'`. We already have a `selectPostsStatus` selector that we can use here, so we can add the `condition` option and check that value:

```ts title="features/posts/postsSlice.ts
export const fetchPosts = createAppAsyncThunk(
Expand Down

0 comments on commit eb25450

Please sign in to comment.