A higher-order component (HOC) is an advanced technique for reusing component logic. Concretely, a higher-order component is a function that takes a component and returns a new component.
Below is sample HOC withTheme and obviously the code received the component, insert the theme data and return decorated component. Annotated or attached the HOC to the class component is called meta-programming using typescript decorator.
Meta-programming is a technique by which you can modify the code dynamically at runtime.
And below is the HOC usage
Ivy is enabler, it enabled HOC and Meta-programming. Be creative, there's so many use-cases can be cater by HOC.
Here is an example of enabling CSS-in-JS using HOC withStyles
And here is some ideas:
return auth data if user have been authenticated
return a router data
return provider reference
Check the codes here https://github.com/abumuawiyah/ng-ivy