Higher-Order Components (HOC) An HOC is an advanced pattern where a function takes a component and returns a new component, adding extra functionality (e.g., withAuth, withRouter). While Hooks have largely replaced HOCs, they are still prevalent. forwardRef By default, you cannot pass a ref to a functional component. React.forwardRef allows a component to forward its ref to a child DOM element, enabling parent components to interact directly with that element (e.g., focusing an input).
Key Takeaways
HOCs wrap components to provide additional capabilities.
forwardRef allows passing refs down to functional components.
Crucial for reusable UI components requiring DOM access.