infinite loop
A loop or cycle that never stops, because the condition that should end it is never reached.
In more detail
It usually shows as a frozen page or a program that never finishes, and often means the code forgets to update the value the stopping condition checks. In a terminal, Control-C interrupts the program. Some loops are deliberately endless and are left from inside with return or break.
Examples
In Idle, Restart Shell stops a runaway loop.In React it often comes from setting state during render, an Effect whose dependency is a new object every render, or getSnapshot returning a new object on each call.Related terms
- while loop — A loop that keeps repeating its block as long as a condition stays true, checking the condition before each pass.
- useEffect — The React hook for running side work, such as adding listeners or changing document.body, after a component renders.
- dependency array — The array of values given to hooks such as useEffect, useMemo and useCallback that tells React when to re-run them.
- reference equality — Comparing two references to see whether they point to the very same object, rather than to objects with equal contents.
Taught in
- Interactive While Loops — Hands-on Python: Complete Video Course & Book
- Graphical Applications With While — Hands-on Python: Complete Video Course & Book
- Chapter Three In One Sitting — Hands-on Python: Complete Video Course & Book
- Avoiding Effect Antipatterns: Derived State And Events — React 19 & Modern Component Architecture
- useSyncExternalStore: Tearing-Free Store Subscriptions — React 19 & Modern Component Architecture
- Suspense Architecture: Promises, Fallbacks, And Co-ordination — React 19 & Modern Component Architecture
- Client-Side Data Fetching Architectures with Suspense — React 19 & Modern Component Architecture
- Functions, Return Values And Recursion — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
References
- Python tutorial: while loops
- Built-in exceptions: KeyboardInterrupt
- React reference: useEffect, my Effect keeps re-running in an infinite cycle