At this point, you can write a Redux app that uses
redux-thunk—a middleware included in Redux toolkit—to permit asynchronous operations, such as fetching data from an API. In this lesson, we will explore some common patterns for managing asynchronous operations and the state changes they cause. We will learn about two Redux toolkit utilities—
createAsyncThunk and the
extraReducers option you can pass to the
createSlice function—that simplify the process of performing asynchronous operations and reflecting their results in state.
This lesson uses Mock Service Worker to replicate the functionality of an external API. To use MSW, you’ll want to use Google Chrome and enable third-party cookies.
Review the diagram shown. In Redux, middleware intercepts actions after dispatching and before passing them along to the reducer.