AI

Not everything needs to be memoized, but expensive calculations that run on every render definitely do.

Your Task:

  • Optimize the PrimeFinder component
  • Finding the 1000th prime number is slow
  • Currently, typing in the input field causes lag because findNthPrime runs on every keystroke
  • Wrap the calculation in useMemo so it only runs when n changes
TypeScript Solution
Loading...

Submit your code to see test results