DEV Community

biplavmz
biplavmz

Posted on

Higher-Order Components

A higher-order component (HOC) is an advanced technique in React for reusing component logic. HOCs are not part of the React API, per se. They are a pattern that emerges from React's compositional nature.

Concretely, a higher-order component is a function that takes a component and returns a new component.

const EnhancedComponent = higherOrderComponent(WrappedComponent);

Whereas a component transforms props into UI, a higher-order component transforms a component into another component.

*what is HigherOrder Function
*

higher order function is a function that it accepts a function as an arrugment 
HOCs basically incorporate the don't-repeat-yourself (DRY) principle of programming, which you've most likely come across at some point in your career as a software developer.

Top comments (0)