August 2017
Beginner
374 pages
10h 41m
English
Now that we know which actions we need to dispatch, let's try to implement an asynchronous action creator that dispatches them.
Instead of returning an action object, we will return a function that takes dispatch as an argument. Then, we can use the dispatch function to dispatch multiple actions. We can now define an asynchronous action creator function:
export const fetchPosts = () => { return function (dispatch) { // ...code... }}
We can shorten the preceding code using arrow functions, as follows:
export const fetchPosts = () => (dispatch) => { // ...code...}
Let's create the asynchronous fetchPosts action creator:
Read now
Unlock full access