Infinite Loop Causes App Hang
After Cursor refactored your component code, the application hangs or becomes unresponsive. useEffect or state updates are causing infinite loops that never terminate.
A circular dependency or missing condition is causing the loop.
Error Messages You Might See
Common Causes
- useEffect updates state that's in dependency array, triggering itself again
- Dependency array missing, useEffect runs every render, updating state
- setState called unconditionally in render path
- React.StrictMode double-mounting triggering loop detection
- Recursive function call with no base case
How to Fix It
Add dependency array to useEffect: useEffect(() => { ... }, [dependency]). Prevent setState in render. Break loops with conditions: if (condition) setState(). Use React DevTools Profiler to detect loops. Check browser console for errors.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I find infinite loops?
Check React DevTools console warnings. Look for setState calls in effect dependencies. Add console.log to trace.
What's a good dependency array?
Include all values used in effect. If effect updates a dependency, use ref or separate effect. Never omit to 'fix' issue.