From the course: React: Design Patterns (2021)
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
ResourceLoader component
From the course: React: Design Patterns (2021)
ResourceLoader component
- [Instructor] All right, so we refactored our current user loader into a more generic user loader that allows us to load different users instead of just the current user from our server. And this is a big step up from what we had before, but we can still take it a little further. What we're going to do, is instead of having a container component that loads a specific type of resource, we're going to have a generic component that allows us to load any type of resource from the server. So, here's what this is going to look like. We're going to start off by creating a new component and we're going to call this component resource loader, and we're actually going to copy some of our user loader code into here. Okay, so we're going to copy that, paste it in here, change the name of our component to resource loader, and there we go. So the first thing we're going to do with our resource loader component is instead of having a…