AI

A common React pitfall is causing infinite loops by creating new object references in the render body and passing them as dependencies to useEffect.

Your Task:

  • Fix the UserProfile component that is currently crashing the browser (simulated)
  • The fetchUser function is being recreated on every render
  • When passed to useEffect, it triggers another render, creating a loop
  • Use useCallback or move the function inside the effect to fix it
TypeScript Solution
Loading...

Submit your code to see test results