From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Introduction to async thunk in RTK

Introduction to async thunk in RTK

In this lesson, we are going to learn about async actions with the help of Redux Thunk in RTK. So, why we need async in Redux? The real-world applications are going to work with APIs. Not usually you are going to work with applications that are not calling the APIs. So, you have a separate backend which is running on a server and your frontend has to call that API to show data so everything gets in sync. It can be like fetching the data or posting form data to the servers and getting counts in dashboards etc. The plain Redux, by default, is synchronous in nature. That means it cannot support APIs on its own. So, the Redux thunk, which is built-in into the Redux toolkit library, it allows us to write async logic, which is calling the APIs and showing the data on screen. The real-world analogy of this can be asking an IT support for help and for this you have to submit a request form from the application so you wait for the response from them. We can have the async support by the…

Contents