1We need a simple React component that shows the 10th Fibonacci number. How would you write the function using memoization so it only computes each value once?
2If you forget to include a dependency array in useMemo for the Fibonacci calculation, what will happen when the component re‑renders?
2-5 years experience
1Your team added an input where users can type N and see the Nth Fibonacci number. The UI becomes sluggish for large N. Walk me through how you would refactor the code using memoization to fix the performance issue.
2After introducing memoization, the component still sometimes shows stale results when the input changes quickly. Why might that happen and how would you debug it?
5-8 years experience
1Design a reusable custom hook called useFibonacci that memoizes results across the whole app. Explain how you would manage the cache, handle cache invalidation, and avoid memory leaks.
2The app now needs to support N values up to 10,000 without blocking the UI. How would you adapt your memoized Fibonacci solution to handle such large inputs efficiently?
8+ years experience
1Multiple front‑ends (React web, React Native) need to compute Fibonacci numbers. Would you keep memoization client‑side, move it to a shared service, or use a hybrid approach? Discuss the trade‑offs in latency, cache consistency, and maintenance.
2Our legacy codebase has a hand‑rolled memoization pattern scattered across components. How would you plan a migration to a centralized, type‑safe solution while minimizing risk to production?
Follow-up Questions
Can you show how the cache is stored and accessed inside the component?
What would you change if the component re‑renders on every keystroke?
How would you test that memoization actually reduces the number of calculations?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.