Should I learn HOCs if I use hooks?
Yes, enough to read them. You will encounter HOCs in legacy code and libraries, so understanding them helps you work with that code. But do not invest in writing them; invest in custom hooks instead.
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.
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.
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.
Still have questions?
Browse all our FAQs or reach out to our support team
