Claude misidentifies React StrictMode's intentional behavior as a bug and attempts impossible solutions

Resolved 💬 2 comments Opened Feb 16, 2026 by coverboy Closed Mar 20, 2026

Problem

React StrictMode intentionally calls effects twice in development mode, but Claude Code misidentifies this as a bug and repeatedly attempts impossible solutions.

Reproduction Steps

  1. React + Next.js project (StrictMode enabled)
  2. Component with useEffect calling an API
  3. User request: "API is called twice in dev mode, make it call only once"
  4. Claude attempts various solutions (isFetchingRef, lastFetchedDepsRef, etc.) but all fail
  5. Code breaks - data no longer displays on screen
  6. Eventually reverted with git restore

Expected Behavior

Claude should understand React's behavior and respond:

  • "Calling effects twice in dev mode is React StrictMode's intentional behavior"
  • "In production, it only runs once"
  • "To call once in dev mode, you can:"
  1. Set reactStrictMode: false
  2. Use caching libraries like React Query or SWR
  • Provide clear explanation and alternatives from the start

Actual Behavior

  • Assumes the problem is solvable and keeps trying
  • Wrong approach: trying to block with component-level refs (StrictMode fully unmounts/remounts components, resetting refs)
  • Adds logic like lastFetchedDepsRef, which causes data not to load
  • Wastes time and tokens, eventually reverts everything

Environment

  • React 18+ with StrictMode
  • Next.js 15
  • useEffect + API calls

Suggestions

  1. Learn React's official StrictMode documentation
  2. Recognize "double execution in dev mode" as normal, unsolvable behavior
  3. For impossible problems: clearly state "This is not solvable" + provide alternatives
  4. Don't waste time on wrong solutions

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗