Debugging
Debug a React bug
Get a structured diagnosis instead of vague “try rewriting it” advice.
Weak
My React app is broken fix it
Strong
You are a senior React engineer.
Task: Diagnose why this component re-renders infinitely and propose a minimal fix.
Context:
- Next.js App Router, React 19
- The bug appears only when the parent passes a new object prop each render
- Code:
```tsx
useEffect(() => { fetchData(filters); }, [filters]);
```
Constraints:
- Do not rewrite the whole file
- Prefer useMemo / stable callbacks over removing the effect
- Call out if the root cause is in the parent
Output format:
1. Root cause (2–4 sentences)
2. Minimal code fix
3. How to verify