Effects visual mental model
Before memorising useEffect, classify the work.
Pure calculations from current props, state, and context.
Work caused by a specific click, submit, drag, or other interaction.
Keep React aligned with a browser API, subscription, timer, connection, or third-party system.
The synchronization lifecycleโ
An Effect is better understood as a process that can start and stop repeatedly.
Dependencies configure the processโ
Example: roomId and serverUrl.
[roomId, serverUrl]
Cleanup the old process, then start the new one.
Cleanup mirrors setupโ
connect ยท subscribe ยท add listener ยท start timer ยท create widget
disconnect ยท unsubscribe ยท remove listener ยท clear timer ยท destroy widget
Should this be an Effect?โ
Strict Mode is a cleanup testโ
If that sequence breaks the integration, the Effect usually has a cleanup or ownership problem. The goal is not to suppress the second setup; the goal is to make the process safe to restart.
Network race mental modelโ
Starts first, finishes later.
Starts second, finishes first.
Use cancellation, framework data APIs, or a server-state library where appropriate.
Keep this picture in your headโ
Continue with useEffect and Synchronizing with External Systems for the complete API, code examples, debugging cases, and production guidance.