What are higher-order components? in REACT

Practice



A higher-order component ( HOC ) is a function that takes a component and returns a new component. In essence it is a pattern that follows from React's compositional nature.

We call them pure components, because they can accept any dynamically provided child components, but they will not modify or copy any behaviour from their input components.

const EnhancedComponent = higherOrderComponent(WrappedComponent)
 
A HOC can be used for many use cases:
  1. Code reuse, logic and bootstrap abstraction.
  2. Render hijacking.
  3. State abstraction and manipulation.
  4. Props manipulation.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone