Google News
logo
ReactJS - Interview Questions
What is a higher-order component in React?
A Higher-Order Component (HOC) is a function that takes a component and returns a new component, simple and enables re-usability. They are generally used when multiple components have to use a common logic. 
 
We call them pure components because they can accept any dynamically provided child component but they won't modify or copy any behavior from their input components.
 
const EnhancedComponent = higherOrderComponent(WrappedComponent)

HOC can be used for many use cases:
 
* Code reuse, logic and bootstrap abstraction.
* Render hijacking.
* State abstraction and manipulation.
* Props manipulation.
Advertisement