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

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…

Contents