From the course: React: Using TypeScript

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Overview of higher-order components (HOCs)

Overview of higher-order components (HOCs)

From the course: React: Using TypeScript

Start my 1-month free trial

Overview of higher-order components (HOCs)

- [Instructor] If you've never worked with HOCs or higher-order components, this is a perfect video for you. Otherwise, feel free to skip it as we'll introduce HOCs in this video. For those who have no idea or are having a hard time grasping the concepts of HOCs, follow along. HOCs, in a very simple way, are functions that take your component and return a new one. Simple as that. So why would you use them? When you have components that are similar, but have slight differences, this would be an ideal case for it. So if we take the two examples on Reacts' library, where one is comment list and the other one is the blogpost, as you can see the functions and the components are quite similar. If you scroll all the way up here, you have the two examples. So we have the comment list here where you see all the same lifecycle methods and this one is literally the same with a few differences here and in the actual pull of the data. In large applications, these patterns will happen over and…

Contents