Years ago when I made my first approach to the React.js environment, I came up with different concepts with different naming. One of those concepts is Higher Order Component (Or HOC), which is without doubt one of the features I like (and use) the most.
As React official documentation says:
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.
React uses HTML to build the UI of our application. With HOC, we can extend that functionality and use not only <div>
, <p>
and <h1>
but also customized components that we create like <Menu>
, <NavigationBar>
, <Carousel>
. High Order Components also allow us to send parameters to these components, custom parameters that we will define. A basic example would be .
#javascript