1We have a simple login page and a Dashboard component. How would you wrap Dashboard with a withAuthentication HOC so that only logged‑in users can see it?
2If the authentication check inside the HOC is asynchronous, what would you render while waiting for the result?
2-5 years experience
1You added withAuthentication to several routes, but after a recent refactor the app crashes when a component receives undefined props. What could be wrong in your HOC implementation?
2Explain how you would modify the HOC to support both client‑side redirects and server‑side redirects in a Next.js app.
5-8 years experience
1Our app now has dozens of protected components and the HOC adds noticeable render latency. How would you optimise the withAuthentication HOC for performance at scale?
2Describe how you would design the HOC to work with multiple auth providers (e.g., JWT, OAuth) without tightly coupling to a specific auth library.
8+ years experience
1We are migrating from a class‑based codebase using HOCs to a function‑component codebase using hooks. How would you plan the transition for authentication while keeping backward compatibility?
2At the organization level, what guidelines would you establish for using withAuthentication versus other patterns (e.g., route guards, context providers) to ensure consistency across teams?
Follow-up Questions
How would you test this HOC?
What are the trade‑offs of using a HOC versus a hook for auth?
How does this affect server‑side rendering?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.