From the course: Building Modern Projects with React

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Keeping track of the loading state

Keeping track of the loading state - React.js Tutorial

From the course: Building Modern Projects with React

Keeping track of the loading state

- [Instructor] All right, so now that we have this server that our front end is going to be loading data from, the next thing that we're going to need to do here is we're going to need to actually create another reducer, right? Another slice, like what we see here, in order to keep track of the loading state of our application, right? When we send a request, as we just did with Postman here, there's a small amount of time where we're still waiting for those todos. And so during that time, we'll probably want to display some sort of loading message so that the user knows why they're not seeing anything in the application. So in order to make this work, we're going to have to create something sort of like this todos slice. But what we're going to do, we'll create a new file and we'll call it something like loadingSlice.js. And this is just going to be sort of a separate slice that keeps track of the current loading state of the todos. So I'm actually going to copy most of this stuff…

Contents