What are higher-order components (HOC)?

HOCs are functions that take a component and return a new component, used to add additional functionality to existing components without modifying them directly.

function withLogger(Component) {
  return function(props) {
    console.log("Component is rendered");
    return <Component {...props} />;
  };
}