From the course: React: Design Patterns

Unlock this course with a free trial

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

UserLoader component

UserLoader component

- [Instructor] Alright, so at this point we've seen how to take a more tightly coupled component like this one, which uses another component directly. And we've seen how to convert it into a more loosely coupled component, which gives us a little bit more flexibility. Now, as a matter of fact, there are a few more steps that we can take in this direction, right, toward flexibility. And the first step that we're going to take is we're going to see how we can add a prop to this current user loader and we're going to achieve a somewhat different functionality with it. So in order to demonstrate this, first of all, let's create a new component. We'll say new file, and we're going to call this one user loader.jsx. And the idea of this one is it's going to allow us to load any user we want from the server by their ID. Now if we open up this server file, right? Take a look at this app, get users slash colon ID thing. This funny little ID thing is called a route parameter. Basically it allows…

Contents