Using Promise Lifecycle Actions From createAsyncThunk

Learn to use the lifecycle actions provided by createAsyncThunk to handle data fetching in your Redux toolkit applications

We'll cover the following

Introduction

To abstract the async state patterns commonly used in thunks, createAsyncThunk makes use of the standard Promise object’s state.

Here’s a reminder. A Javascript promise can only be in one of these states:

  • Pending: Initial state that is neither fulfilled nor rejected.
  • Fulfilled: The operation was completed successfully.
  • Rejected: The operation failed.

As you may have figured out, pending could be likened to the loading state, fulfilled to the success state, and rejected could be likened to the error state.

Get hands-on with 1400+ tech skills courses.