Skip to content

Commit

Permalink
Fix naming when thunk-ifying AddPostForm.js. (#3906)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzhang committed Oct 16, 2020
1 parent 2baca9c commit b3165d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/tutorials/essentials/part-5-async-logic.md
Expand Up @@ -704,7 +704,7 @@ const postsSlice = createSlice({

### Checking Thunk Results in Components

Finally, we'll update `<AddPostForm>` to dispatch the `addNewPost` thunk instead the old `postUpdated` action. Since this is another API call to the server, it will take some time and _could_ fail. The `addNewPost()` thunk will automatically dispatch its `pending/fulfilled/rejected` actions to the Redux store, which we're already handling. We _could_ track the request status in `postsSlice` using a second loading enum if we wanted to, but for this example let's keep the loading state tracking limited to the component.
Finally, we'll update `<AddPostForm>` to dispatch the `addNewPost` thunk instead the old `postAdded` action. Since this is another API call to the server, it will take some time and _could_ fail. The `addNewPost()` thunk will automatically dispatch its `pending/fulfilled/rejected` actions to the Redux store, which we're already handling. We _could_ track the request status in `postsSlice` using a second loading enum if we wanted to, but for this example let's keep the loading state tracking limited to the component.

It would be good if we can at least disable the "Save Post" button while we're waiting for the request, so the user can't accidentally try to save a post twice. If the request fails, we might also want to show an error message here in the form, or perhaps just log it to the console.

Expand Down

0 comments on commit b3165d0

Please sign in to comment.