There are different ways in which we can build shareable code in react:
1
Hooks
2
Higher Order Components
3
Render Props
4
Component composition
Scenario Questions
0-2 years experience
1How would you extract a button component so it can be used on two different pages without duplicating code?
2If you create a custom hook for data fetching, where do you place the file and how do you import it in a component?
3What happens if you import the same component using two different relative paths in a small React app?
2-5 years experience
1We need a modal that appears in several places but each usage requires slightly different styling. How would you design it for reuse and what pitfalls might you watch for?
2After moving a shared utility into a new folder, the production build started throwing ‘module not found’ errors. Walk me through how you’d debug this.
3Why did wrapping a list item with a higher‑order component for authentication cause unexpected re‑renders, and how would you fix it?
5-8 years experience
1Our organization wants a shared component library across multiple React apps with different theming needs. How would you structure the library, handle versioning, and keep bundle impact low?
2Introducing a custom‑hook library caused a memory leak in a high‑frequency component. How would you identify the leak and resolve it?
3Compare using a monorepo versus separate repos for sharing UI components across teams. What are the trade‑offs in terms of CI, dependency management, and team autonomy?
8+ years experience
1We have legacy codebases using class components and a new codebase using functional components with hooks. Outline a migration strategy for shared utilities and components that minimizes disruption.
2Design a governance model for a company‑wide React component library that balances product‑team autonomy with consistency and long‑term maintainability.
3A critical security vulnerability is discovered in a shared npm package used by dozens of services. How would you coordinate the fix and rollout across the organization?
Follow-up Questions
What trade‑offs did you consider when choosing that pattern?
How would you test that the reusable piece works in all contexts?
What impact does this have on bundle size or load performance?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.