What this thread does
Do first: compare consecutive effect dependency values with Object.is and identify which state update recreates the object that triggers the next effect.
Short answer
As of November 2026, this card targets React 19.3.1 and current hook docs. An infinite effect cycle needs both a state update and a resulting dependency change (useEffect). You don’t need Effects to transform data for rendering (unnecessary effects).
Choose / don't choose
- Object used only by an effect: create it inside the effect from primitive reactive inputs; don't depend on a fresh wrapper object each render (dependencies).
- Object received from a parent: read
roomIdandserverUrlfromoptionsoutside the Effect, and list both as dependencies. Don't drop reactive fields merely to quiet the linter (extract inputs). - Shared expensive object: consider
useMemoonly after simpler ownership changes; don't use its cache as a semantic guarantee because React can discard it (memoization).
Not for: class-to-hooks migration planning; see react-class-to-hooks-codemod-then-e2e.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
useEffect dependencies | Inline [roomId, serverUrl] when both are the reactive strings read by setup | React 19.3 docs | Primitive inputs |
useState updater | Pass a pure function of previous state; it returns the next state without mutating previous objects | React 19.3 docs | Updater API |
Object.is | Compare dependency array indices 0 and 1 | React 19.3 docs | Dependency diagnosis |
useMemo | Supply all inputs; performance cache only, not guaranteed object lifetime | React 19.3 docs | Memo |
StrictMode | Keep development checks enabled; setup/cleanup must tolerate the extra cycle | React 19.3 docs | Strict Mode |
Keep all other reactive inputs (dependencies). Returning an identical state can avoid an unnecessary update, but mutating the previous object is invalid (state API).
Order of operations
1. On mount, setup starts the external synchronization. 2. After changed dependencies, cleanup runs with the old props and state. On unmount, cleanup runs one final time (effect lifecycle). 3. Strict Mode adds one extra setup+cleanup cycle in development for every Effect. A nested Strict Mode boundary without a strict root does not add the initial effect rerun, because that sequence would not match production parent/child behavior (caveat). 4. To diagnose: store arrays from different re-renders as console globals, then compare dependencies at indices 0 and 1 with Object.is. Replace the unstable cause, and repeat an unrelated render to inspect whether synchronization restarts (effect debugging).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
My Effect keeps re-running in an infinite cycle | State writes change an effect dependency repeatedly | Remove redundant state, use a previous-state updater, or move object creation inside setup | React, palerdot's October 9, 2020 report |
React Hook useEffect has a missing dependency: 'roomId' | The linter suggests the correct dependencies when Effect dependencies are empty | Change the code's ownership or include roomId; do not suppress the warning | Dependencies |
Missing
- The linked source does not confirm: A functional updater removes the need to read the previous object outside that updater, but it does not neutralize
[state]if the effect still depends onstate. - The application's object fields determine the complete dependency list; there is no universal array that fixes every loop.
- Extra development setup alone is not evidence of an infinite cycle.
Checked
2026-11-12; React 19.3.1 release and current hook docs. Sources read: effect, dependency removal, unnecessary effects, state, memo, Strict Mode and palerdot's dated issue. No component execution is claimed.
Started from a post by @React, packaged by the editor. Original post