From the course: React: Design Patterns

Unlock this course with a free trial

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

DataLoader component

DataLoader component

- [Instructor] All right, so we've taken a series of steps over the past few videos to make this component more and more flexible. We went from current user to user loader to resource loader. So now we're going to reach sort of the peak of flexibility by creating something called a data loader that will in theory be able to get data from pretty much anywhere. So here's how this is going to work. First things first, let's create the new file. We're going to call it data loader. There we go. Nope, let me try that again .JSX. We'll start off with the resource loader code just because there's going to be a lot of shared code between those two. So we'll paste that there. And just to be clear here, there is a lot of duplicated code between these different loaders. In many cases, you wouldn't actually have each one of these in the same application, right? So you wouldn't have data loader and user loader and current user loader all in the same app, at least not in the form that we have them…

Contents