1We have a Button component that needs to log clicks for analytics. How would you create a higher‑order component to add this logging without changing the Button code?
2If you wrap a component with a HOC that adds a new prop, what happens to the original component’s propTypes and defaultProps?
2-5 years experience
1Our team introduced a withTheme HOC, but after a recent refactor the UI stopped receiving the theme prop. Walk me through how you would debug the issue.
2When deciding between using connect from Redux versus a custom withAuth HOC, what factors would influence your choice in a feature that requires both authentication state and UI theming?
5-8 years experience
1We have a page that composes three HOCs (withRouter, withPermissions, withFeatureToggle). Performance profiling shows extra renders. How would you redesign or optimize this composition?
2Explain how you would implement a generic HOC that forwards refs correctly while also injecting props, and why ref forwarding matters in a large component library.
8+ years experience
1Our legacy codebase uses many HOCs for cross‑cutting concerns, but the new team prefers hooks. How would you plan a migration strategy that minimizes risk and maintains backward compatibility?
2At a system‑level, what are the architectural trade‑offs of relying heavily on HOCs for concerns like logging, error handling, and theming across multiple product lines?
Follow-up Questions
What problems can arise if you stack many HOCs together?
How would you test a component that is wrapped by an HOC?
Can you achieve the same result with hooks, and what trade‑offs exist?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.