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 - React.js Tutorial
From the course: React: Design Patterns
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
-
-
-
-
(Locked)
What are container components?1m 50s
-
Server instructions4m 3s
-
Loading the current user8m 53s
-
(Locked)
CurrentUserLoader component5m 57s
-
(Locked)
UserLoader component6m 14s
-
(Locked)
ResourceLoader component7m 30s
-
(Locked)
DataLoader component10m 24s
-
(Locked)
Solution: Loading data from localStorage2m 46s
-
(Locked)
-
-
-
-
-
-