From the course: React: Components, Context, and Accessibility
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Working with higher-order components - React.js Tutorial
From the course: React: Components, Context, and Accessibility
Working with higher-order components
- [Instructor] A higher order component is a function that takes in a component and returns a new component. It provides a way to share data between components through composition. The place I want to get started with this is to get rid of all of our code from the previous lesson and we're going to replace it with our higher order component. Now the component that I wanna render here is gonna be called random users. I'll call it RandomMeUsers, and here we're going to start to create our people list. So the RandomMeUsers is going to take in some data and display it. And the display component is going to be called PeopleList. So const PeopleList should take in some data. From here we want to render an ordered list. So the PeopleList is gonna be a pretty textbook presentation component. It's just gonna render some tags and it's going to load some data. So the data is gonna come from data.results.map. When we map over the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Understanding the context API3m 45s
-
(Locked)
Using context3m 45s
-
(Locked)
Referencing context in stateless functional components2m 34s
-
(Locked)
Working with higher-order components7m 31s
-
(Locked)
Working with render props3m 54s
-
(Locked)
Render props in the wild: React Apollo46s
-
(Locked)
Solution: Building a context-based theme system2m 24s
-
(Locked)
-
-
-