When do HOCs still appear?
In older codebases, in some libraries like React Redux's connect, and in code that wraps third-party components. You need to understand them to read and work with that code, even if you do not write new HOCs.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Are Higher-Order Components Still Useful in Modern React?
For new logic reuse, no. Custom hooks solve the same problems more cleanly. HOCs remain useful mainly for reading legacy code and some library integrations like React Redux's connect. Understand them, but write hooks.
Because hooks compose by calling multiple hooks in one component, while HOCs compose by nesting wrappers, which gets ugly fast: withAuth(withTheme(withData(Component))). Hooks avoid nesting and prop collisions entirely.
Yes, usually. Most HOCs can be refactored into a custom hook that returns the shared logic. Components call the hook directly, removing the wrapper layer and its issues like nesting and prop collisions.
Still have questions?
Browse all our FAQs or reach out to our support team
