From the course: React: Design Patterns
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
CurrentUserLoader component - React.js Tutorial
From the course: React: Design Patterns
CurrentUserLoader component
- [Narrator] All right, so now that we've seen the basics of loading data from a server and, you know, displaying that in a component, and we've seen what could be a slightly better way, right? This way is very similar to what we saw with the layout components, where it allows us to really separate the way that data's being rendered from the way that it's being loaded. Okay, so what we're going to want to do here is, first of all instead of calling this "CurrentUserInfo," we'll call this something like "CurrentUserLoader." All right, so "CurrentUser" and "CurrentUserLoader." And what we want to be able to do, as I said previously, is automatically have this UserInfo component get access to the data loaded by this component that's surrounding it. All right? So here's what this is going to look like, and by the way, this is also a common pattern that you'll see sometimes used with libraries like React Router, right, so it does have a pretty wide-ranging application beyond just loading…
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)
-
-
-
-
-
-