HOCs are functions that take a component and return a new component with additional props or behavior.
They're used for cross-cutting concerns like authentication, logging, or styling.
HOCs are a pattern for reusing component logic.
They're not part of the React API but are a pattern that emerges from React's compositional nature.
// HOC for authentication function withAuth(WrappedComponent) { return function AuthenticatedComponent(props) { const [isAuthenticated, setIsAuthenticated] = useState(false);
}; }
// Usage const ProtectedComponent = withAuth(MyComponent);