Higher-order components (HOC) are an advanced technique in React that is used for reusing component logic. It is the function that takes the original component and returns the new enhanced component.
It doesn’t modify the input component directly. Instead, they return a new component with enhanced behavior.
They allow you to reuse component logic across multiple components without duplicating it.
They are pure functions that accept a component and return a new component.
withName adds a name prop with the value "GeeksforGeeks"
App displays the name inside an <h1> tag
The wrapped component renders “GeeksforGeeks” in the browser
Example 2: In this example let's implement some logic. Let's make a counter app. In HighOrder.js, we pass the handleclick and show props for calling the functionality of the component.