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
- React + Next.js project (StrictMode enabled)
- Component with useEffect calling an API
- User request: "API is called twice in dev mode, make it call only once"
- Claude attempts various solutions (isFetchingRef, lastFetchedDepsRef, etc.) but all fail
- Code breaks - data no longer displays on screen
- 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:"
- Set
reactStrictMode: false - 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
- Learn React's official StrictMode documentation
- Recognize "double execution in dev mode" as normal, unsolvable behavior
- For impossible problems: clearly state "This is not solvable" + provide alternatives
- Don't waste time on wrong solutions
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗